Java Code Examples for com.sun.tools.javac.code.Symbol.ClassSymbol#getEnclosedElements()

The following examples show how to use com.sun.tools.javac.code.Symbol.ClassSymbol#getEnclosedElements() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TreeLoader.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void fillArtificalParamNames(final ClassSymbol clazz) {
    for (Symbol s : clazz.getEnclosedElements()) {
        if (s instanceof MethodSymbol) {
            MethodSymbol ms = (MethodSymbol) s;

            if (ms.getParameters().isEmpty()) {
                continue;
            }
            
            Set<String> usedNames = new HashSet<String>();
            
            for (VarSymbol vs : ms.getParameters()) {
                String name = JavaSourceAccessor.getINSTANCE().generateReadableParameterName(vs.asType().toString(), usedNames);

                vs.setName(clazz.name.table.fromString(name));
            }
        }
    }
}
 
Example 2
Source File: JNIWriter.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected void writeMethods(PrintWriter out, ClassSymbol sym, String cname)
        throws IOException, TypeSignature.SignatureException {
    List<Symbol> classmethods = sym.getEnclosedElements();
    for (Symbol md : classmethods) {
        if (isNative(md)) {
            TypeSignature newtypesig = new TypeSignature(types);
            CharSequence methodName = md.getSimpleName();
            boolean isOverloaded = false;
            for (Symbol md2 : classmethods) {
                if ((md2 != md)
                        && (methodName.equals(md2.getSimpleName()))
                        && isNative(md2)) {
                    isOverloaded = true;
                }
            }
            out.println("/*");
            out.println(" * Class:     " + cname);
            out.println(" * Method:    " + encode(methodName, EncoderType.FIELDSTUB));
            out.println(" * Signature: " + newtypesig.getSignature(md.type));
            out.println(" */");
            out.println("JNIEXPORT " + jniType(types.erasure(md.type.getReturnType()))
                    + " JNICALL " + encodeMethod(md, sym, isOverloaded));
            out.print("  (JNIEnv *, ");
            out.print((md.isStatic())
                    ? "jclass"
                    : "jobject");
            for (Type arg : types.erasure(md.type.getParameterTypes())) {
                out.print(", ");
                out.print(jniType(arg));
            }
            out.println(");");
            out.println();
        }
    }
}
 
Example 3
Source File: JNIWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void writeMethods(PrintWriter out, ClassSymbol sym, String cname)
        throws IOException, TypeSignature.SignatureException {
    List<Symbol> classmethods = sym.getEnclosedElements();
    for (Symbol md : classmethods) {
        if (isNative(md)) {
            TypeSignature newtypesig = new TypeSignature(types);
            CharSequence methodName = md.getSimpleName();
            boolean isOverloaded = false;
            for (Symbol md2 : classmethods) {
                if ((md2 != md)
                        && (methodName.equals(md2.getSimpleName()))
                        && isNative(md2)) {
                    isOverloaded = true;
                }
            }
            out.println("/*");
            out.println(" * Class:     " + cname);
            out.println(" * Method:    " + encode(methodName, EncoderType.FIELDSTUB));
            out.println(" * Signature: " + newtypesig.getSignature(md.type));
            out.println(" */");
            out.println("JNIEXPORT " + jniType(types.erasure(md.type.getReturnType()))
                    + " JNICALL " + encodeMethod(md, sym, isOverloaded));
            out.print("  (JNIEnv *, ");
            out.print((md.isStatic())
                    ? "jclass"
                    : "jobject");
            for (Type arg : types.erasure(md.type.getParameterTypes())) {
                out.print(", ");
                out.print(jniType(arg));
            }
            out.println(");");
            out.println();
        }
    }
}