ClassHasNativeVisitor implements ClassVisitor { public boolean hasNativeMethods() { return mHasNativeMethods; }  boolean hasNativeMethods(); void visit(int version, int access, String name, String signature,
            String superName, String[] interfaces); AnnotationVisitor visitAnnotation(String desc, boolean visible); void visitAttribute(Attribute attr); void visitEnd(); FieldVisitor visitField(int access, String name, String desc,
            String signature, Object value); void visitInnerClass(String name, String outerName,
            String innerName, int access); MethodVisitor visitMethod(int access, String name, String desc,
            String signature, String[] exceptions); void visitOuterClass(String owner, String name, String desc); void visitSource(String source, String debug);  }
@Test public void testHasNative() throws IOException { MockClassHasNativeVisitor cv = new MockClassHasNativeVisitor(); String className = this.getClass().getCanonicalName() + "$" + ClassWithNative.class.getSimpleName(); ClassReader cr = new ClassReader(className); cr.accept(cv, 0 ); assertArrayEquals(new String[] { "native_method" }, cv.getMethodsFound()); assertTrue(cv.hasNativeMethods()); }
@Test public void testHasNoNative() throws IOException { MockClassHasNativeVisitor cv = new MockClassHasNativeVisitor(); String className = this.getClass().getCanonicalName() + "$" + ClassWithoutNative.class.getSimpleName(); ClassReader cr = new ClassReader(className); cr.accept(cv, 0 ); assertArrayEquals(new String[0], cv.getMethodsFound()); assertFalse(cv.hasNativeMethods()); }