langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java
changeset 22163 3651128c74eb
parent 22159 682da512ec17
child 23117 862f9f689d0b
equal deleted inserted replaced
22162:3b3e23e67329 22163:3651128c74eb
    76  *  If you write code that depends on this, you do so at your own risk.
    76  *  If you write code that depends on this, you do so at your own risk.
    77  *  This code and its internal interfaces are subject to change or
    77  *  This code and its internal interfaces are subject to change or
    78  *  deletion without notice.</b>
    78  *  deletion without notice.</b>
    79  */
    79  */
    80 public class JNIWriter {
    80 public class JNIWriter {
    81     protected static final Context.Key<JNIWriter> jniWriterKey =
    81     protected static final Context.Key<JNIWriter> jniWriterKey = new Context.Key<>();
    82         new Context.Key<JNIWriter>();
       
    83 
    82 
    84     /** Access to files. */
    83     /** Access to files. */
    85     private final JavaFileManager fileManager;
    84     private final JavaFileManager fileManager;
    86 
    85 
    87     JavacElements elements;
    86     JavacElements elements;
   238 
   237 
   239     /**
   238     /**
   240      * Including super class fields.
   239      * Including super class fields.
   241      */
   240      */
   242     List<VariableElement> getAllFields(TypeElement subclazz) {
   241     List<VariableElement> getAllFields(TypeElement subclazz) {
   243         List<VariableElement> fields = new ArrayList<VariableElement>();
   242         List<VariableElement> fields = new ArrayList<>();
   244         TypeElement cd = null;
   243         TypeElement cd = null;
   245         Stack<TypeElement> s = new Stack<TypeElement>();
   244         Stack<TypeElement> s = new Stack<>();
   246 
   245 
   247         cd = subclazz;
   246         cd = subclazz;
   248         while (true) {
   247         while (true) {
   249             s.push(cd);
   248             s.push(cd);
   250             TypeElement c = (TypeElement) (types.asElement(cd.getSuperclass()));
   249             TypeElement c = (TypeElement) (types.asElement(cd.getSuperclass()));
   353                                                (longName) ?
   352                                                (longName) ?
   354                                                Mangle.Type.METHOD_JNI_LONG :
   353                                                Mangle.Type.METHOD_JNI_LONG :
   355                                                Mangle.Type.METHOD_JNI_SHORT));
   354                                                Mangle.Type.METHOD_JNI_SHORT));
   356                 print(out, "  (JNIEnv *, ");
   355                 print(out, "  (JNIEnv *, ");
   357                 List<? extends VariableElement> paramargs = md.getParameters();
   356                 List<? extends VariableElement> paramargs = md.getParameters();
   358                 List<TypeMirror> args = new ArrayList<TypeMirror>();
   357                 List<TypeMirror> args = new ArrayList<>();
   359                 for (VariableElement p: paramargs) {
   358                 for (VariableElement p: paramargs) {
   360                     args.add(types.erasure(p.asType()));
   359                     args.add(types.erasure(p.asType()));
   361                 }
   360                 }
   362                 if (md.getModifiers().contains(Modifier.STATIC))
   361                 if (md.getModifiers().contains(Modifier.STATIC))
   363                     print(out, "jclass");
   362                     print(out, "jclass");
   491             public static final int JNI              = 4;
   490             public static final int JNI              = 4;
   492             public static final int SIGNATURE        = 5;
   491             public static final int SIGNATURE        = 5;
   493             public static final int METHOD_JDK_1     = 6;
   492             public static final int METHOD_JDK_1     = 6;
   494             public static final int METHOD_JNI_SHORT = 7;
   493             public static final int METHOD_JNI_SHORT = 7;
   495             public static final int METHOD_JNI_LONG  = 8;
   494             public static final int METHOD_JNI_LONG  = 8;
   496         };
   495         }
   497 
   496 
   498         private Elements elems;
   497         private Elements elems;
   499         private Types types;
   498         private Types types;
   500 
   499 
   501         Mangle(Elements elems, Types types) {
   500         Mangle(Elements elems, Types types) {
   669          */
   668          */
   670         public String getTypeSignature(String javasignature, TypeMirror returnType)
   669         public String getTypeSignature(String javasignature, TypeMirror returnType)
   671                 throws SignatureException {
   670                 throws SignatureException {
   672             String signature = null; //Java type signature.
   671             String signature = null; //Java type signature.
   673             String typeSignature = null; //Internal type signature.
   672             String typeSignature = null; //Internal type signature.
   674             List<String> params = new ArrayList<String>(); //List of parameters.
   673             List<String> params = new ArrayList<>(); //List of parameters.
   675             String paramsig = null; //Java parameter signature.
   674             String paramsig = null; //Java parameter signature.
   676             String paramJVMSig = null; //Internal parameter signature.
   675             String paramJVMSig = null; //Internal parameter signature.
   677             String returnSig = null; //Java return type signature.
   676             String returnSig = null; //Java return type signature.
   678             String returnJVMType = null; //Internal return type signature.
   677             String returnJVMType = null; //Internal return type signature.
   679             int dimensions = 0; //Array dimension.
   678             int dimensions = 0; //Array dimension.