Search in sources :

Example 21 with Method

use of com.sun.tools.classfile.Method in project ceylon-compiler by ceylon.

the class FindNativeFiles method isNativeClass.

boolean isNativeClass(JarFile jar, JarEntry entry) throws IOException, ConstantPoolException {
    String name = entry.getName();
    if (name.startsWith("META-INF") || !name.endsWith(".class"))
        return false;
    // String className = name.substring(0, name.length() - 6).replace("/", ".");
    // System.err.println("check " + className);
    InputStream in = jar.getInputStream(entry);
    ClassFile cf = ClassFile.read(in);
    in.close();
    for (int i = 0; i < cf.methods.length; i++) {
        Method m = cf.methods[i];
        if (m.access_flags.is(AccessFlags.ACC_NATIVE)) {
            // System.err.println(className);
            return true;
        }
    }
    return false;
}
Also used : ClassFile(com.sun.tools.classfile.ClassFile) InputStream(java.io.InputStream) Method(com.sun.tools.classfile.Method)

Aggregations

Method (com.sun.tools.classfile.Method)21 ClassFile (com.sun.tools.classfile.ClassFile)15 Code_attribute (com.sun.tools.classfile.Code_attribute)10 Instruction (com.sun.tools.classfile.Instruction)6 InputStream (java.io.InputStream)5 File (java.io.File)4 Field (com.sun.tools.classfile.Field)3 Exception_data (com.sun.tools.classfile.Code_attribute.Exception_data)2 ConstantPool (com.sun.tools.classfile.ConstantPool)2 ConstantPoolException (com.sun.tools.classfile.ConstantPoolException)2 LocalVariableTypeTable_attribute (com.sun.tools.classfile.LocalVariableTypeTable_attribute)2 DataInputStream (java.io.DataInputStream)2 FileInputStream (java.io.FileInputStream)2 AccessFlags (com.sun.tools.classfile.AccessFlags)1 Attribute (com.sun.tools.classfile.Attribute)1 Attributes (com.sun.tools.classfile.Attributes)1 ClassWriter (com.sun.tools.classfile.ClassWriter)1 Descriptor (com.sun.tools.classfile.Descriptor)1 InvalidDescriptor (com.sun.tools.classfile.Descriptor.InvalidDescriptor)1 DescriptorException (com.sun.tools.classfile.DescriptorException)1