Java Code Examples for java.lang.reflect.Modifier#NATIVE
The following examples show how to use
java.lang.reflect.Modifier#NATIVE .
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: ExternalPackages.java From netbeans with Apache License 2.0 | 6 votes |
private static int getModifiers(ClassInfo ci, int mIndex) { int modifiers = 0; if (ci.isMethodAbstract(mIndex)) { modifiers += Modifier.ABSTRACT; } if (ci.isMethodPrivate(mIndex)) { modifiers += Modifier.PRIVATE; } if (ci.isMethodProtected(mIndex)) { modifiers += Modifier.PROTECTED; } if (ci.isMethodPublic(mIndex)) { modifiers += Modifier.PUBLIC; } if (ci.isMethodFinal(mIndex)) { modifiers += Modifier.FINAL; } if (ci.isMethodStatic(mIndex)) { modifiers += Modifier.STATIC; } if (ci.isMethodNative(mIndex)) { modifiers += Modifier.NATIVE; } return modifiers; }
Example 2
Source File: FieldTest.java From j2objc with Apache License 2.0 | 6 votes |
/** * java.lang.reflect.Field#getModifiers() */ public void test_getModifiers() { // Test for method int java.lang.reflect.Field.getModifiers() TestField x = new TestField(); Field f = null; try { f = TestField.class.getDeclaredField("prsttrvol"); } catch (Exception e) { fail("Exception during getModifiers test: " + e.toString()); } int mod = f.getModifiers(); int mask = (Modifier.PROTECTED | Modifier.STATIC) | (Modifier.TRANSIENT | Modifier.VOLATILE); int nmask = (Modifier.PUBLIC | Modifier.NATIVE); assertTrue("Returned incorrect field modifiers: ", ((mod & mask) == mask) && ((mod & nmask) == 0)); }
Example 3
Source File: StubGenerator.java From gwtmockito with Apache License 2.0 | 6 votes |
/** Returns whether the behavior of the given method should be replaced. */ public static boolean shouldStub(CtMethod method, Collection<Class<?>> classesToStub) { // Stub any methods for which we have given explicit implementations if (STUB_METHODS.containsKey(new ClassAndMethod( method.getDeclaringClass().getName(), method.getName()))) { return true; } // Stub all non-abstract methods of classes for which stubbing has been requested for (Class<?> clazz : classesToStub) { if (declaringClassIs(method, clazz) && (method.getModifiers() & Modifier.ABSTRACT) == 0) { return true; } } // Stub all native methods if ((method.getModifiers() & Modifier.NATIVE) != 0) { return true; } return false; }
Example 4
Source File: DocEnv.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Convert modifier bits from private coding used by * the compiler to that of java.lang.reflect.Modifier. */ static int translateModifiers(long flags) { int result = 0; if ((flags & Flags.ABSTRACT) != 0) result |= Modifier.ABSTRACT; if ((flags & Flags.FINAL) != 0) result |= Modifier.FINAL; if ((flags & Flags.INTERFACE) != 0) result |= Modifier.INTERFACE; if ((flags & Flags.NATIVE) != 0) result |= Modifier.NATIVE; if ((flags & Flags.PRIVATE) != 0) result |= Modifier.PRIVATE; if ((flags & Flags.PROTECTED) != 0) result |= Modifier.PROTECTED; if ((flags & Flags.PUBLIC) != 0) result |= Modifier.PUBLIC; if ((flags & Flags.STATIC) != 0) result |= Modifier.STATIC; if ((flags & Flags.SYNCHRONIZED) != 0) result |= Modifier.SYNCHRONIZED; if ((flags & Flags.TRANSIENT) != 0) result |= Modifier.TRANSIENT; if ((flags & Flags.VOLATILE) != 0) result |= Modifier.VOLATILE; return result; }
Example 5
Source File: DocEnv.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Convert modifier bits from private coding used by * the compiler to that of java.lang.reflect.Modifier. */ static int translateModifiers(long flags) { int result = 0; if ((flags & Flags.ABSTRACT) != 0) result |= Modifier.ABSTRACT; if ((flags & Flags.FINAL) != 0) result |= Modifier.FINAL; if ((flags & Flags.INTERFACE) != 0) result |= Modifier.INTERFACE; if ((flags & Flags.NATIVE) != 0) result |= Modifier.NATIVE; if ((flags & Flags.PRIVATE) != 0) result |= Modifier.PRIVATE; if ((flags & Flags.PROTECTED) != 0) result |= Modifier.PROTECTED; if ((flags & Flags.PUBLIC) != 0) result |= Modifier.PUBLIC; if ((flags & Flags.STATIC) != 0) result |= Modifier.STATIC; if ((flags & Flags.SYNCHRONIZED) != 0) result |= Modifier.SYNCHRONIZED; if ((flags & Flags.TRANSIENT) != 0) result |= Modifier.TRANSIENT; if ((flags & Flags.VOLATILE) != 0) result |= Modifier.VOLATILE; return result; }
Example 6
Source File: DocEnv.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Convert modifier bits from private coding used by * the compiler to that of java.lang.reflect.Modifier. */ static int translateModifiers(long flags) { int result = 0; if ((flags & Flags.ABSTRACT) != 0) result |= Modifier.ABSTRACT; if ((flags & Flags.FINAL) != 0) result |= Modifier.FINAL; if ((flags & Flags.INTERFACE) != 0) result |= Modifier.INTERFACE; if ((flags & Flags.NATIVE) != 0) result |= Modifier.NATIVE; if ((flags & Flags.PRIVATE) != 0) result |= Modifier.PRIVATE; if ((flags & Flags.PROTECTED) != 0) result |= Modifier.PROTECTED; if ((flags & Flags.PUBLIC) != 0) result |= Modifier.PUBLIC; if ((flags & Flags.STATIC) != 0) result |= Modifier.STATIC; if ((flags & Flags.SYNCHRONIZED) != 0) result |= Modifier.SYNCHRONIZED; if ((flags & Flags.TRANSIENT) != 0) result |= Modifier.TRANSIENT; if ((flags & Flags.VOLATILE) != 0) result |= Modifier.VOLATILE; return result; }
Example 7
Source File: MemberName.java From jdk-1.7-annotated with Apache License 2.0 | 5 votes |
/** Utility method to query if this member is a method handle invocation (invoke or invokeExact). */ public boolean isMethodHandleInvoke() { final int bits = Modifier.NATIVE | Modifier.FINAL; final int negs = Modifier.STATIC; if (testFlags(bits | negs, bits) && clazz == MethodHandle.class) { return name.equals("invoke") || name.equals("invokeExact"); } return false; }
Example 8
Source File: DocEnv.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Convert modifier bits from private coding used by * the compiler to that of java.lang.reflect.Modifier. */ static int translateModifiers(long flags) { int result = 0; if ((flags & Flags.ABSTRACT) != 0) result |= Modifier.ABSTRACT; if ((flags & Flags.FINAL) != 0) result |= Modifier.FINAL; if ((flags & Flags.INTERFACE) != 0) result |= Modifier.INTERFACE; if ((flags & Flags.NATIVE) != 0) result |= Modifier.NATIVE; if ((flags & Flags.PRIVATE) != 0) result |= Modifier.PRIVATE; if ((flags & Flags.PROTECTED) != 0) result |= Modifier.PROTECTED; if ((flags & Flags.PUBLIC) != 0) result |= Modifier.PUBLIC; if ((flags & Flags.STATIC) != 0) result |= Modifier.STATIC; if ((flags & Flags.SYNCHRONIZED) != 0) result |= Modifier.SYNCHRONIZED; if ((flags & Flags.TRANSIENT) != 0) result |= Modifier.TRANSIENT; if ((flags & Flags.VOLATILE) != 0) result |= Modifier.VOLATILE; return result; }
Example 9
Source File: DeclaredFieldsSerializer.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
private static void visitFields(@Nonnull final Object object, @Nonnull final FieldVisitor visitor) { for (final Field f : object.getClass().getDeclaredFields()) { if ((f.getModifiers() & (Modifier.FINAL | Modifier.NATIVE | Modifier.STATIC | Modifier.TRANSIENT)) == 0) { f.setAccessible(true); visitor.visitField(object, f, f.getName(), f.getType()); } } }
Example 10
Source File: DocEnv.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Convert modifier bits from private coding used by * the compiler to that of java.lang.reflect.Modifier. */ static int translateModifiers(long flags) { int result = 0; if ((flags & Flags.ABSTRACT) != 0) result |= Modifier.ABSTRACT; if ((flags & Flags.FINAL) != 0) result |= Modifier.FINAL; if ((flags & Flags.INTERFACE) != 0) result |= Modifier.INTERFACE; if ((flags & Flags.NATIVE) != 0) result |= Modifier.NATIVE; if ((flags & Flags.PRIVATE) != 0) result |= Modifier.PRIVATE; if ((flags & Flags.PROTECTED) != 0) result |= Modifier.PROTECTED; if ((flags & Flags.PUBLIC) != 0) result |= Modifier.PUBLIC; if ((flags & Flags.STATIC) != 0) result |= Modifier.STATIC; if ((flags & Flags.SYNCHRONIZED) != 0) result |= Modifier.SYNCHRONIZED; if ((flags & Flags.TRANSIENT) != 0) result |= Modifier.TRANSIENT; if ((flags & Flags.VOLATILE) != 0) result |= Modifier.VOLATILE; return result; }
Example 11
Source File: HookManager.java From RocooFix with MIT License | 4 votes |
private static Method hookMethodArt(Method origin, Method hook) { ArtMethod artOrigin = ArtMethod.of(origin); ArtMethod artHook = ArtMethod.of(hook); Method backup = artOrigin.backup().getMethod(); backup.setAccessible(true); long originPointFromQuickCompiledCode = artOrigin.getEntryPointFromQuickCompiledCode(); long originEntryPointFromJni = artOrigin.getEntryPointFromJni(); long originEntryPointFromInterpreter = artOrigin.getEntryPointFromInterpreter(); long originDeclaringClass = artOrigin.getDeclaringClass(); long originAccessFlags = artOrigin.getAccessFlags(); long originDexCacheResolvedMethods = artOrigin.getDexCacheResolvedMethods(); long originDexCacheResolvedTypes = artOrigin.getDexCacheResolvedTypes(); long originDexCodeItemOffset = artOrigin.getDexCodeItemOffset(); long originDexMethodIndex = artOrigin.getDexMethodIndex(); long hookPointFromQuickCompiledCode = artHook.getEntryPointFromQuickCompiledCode(); long hookEntryPointFromJni = artHook.getEntryPointFromJni(); long hookEntryPointFromInterpreter = artHook.getEntryPointFromInterpreter(); long hookDeclaringClass = artHook.getDeclaringClass(); long hookAccessFlags = artHook.getAccessFlags(); long hookDexCacheResolvedMethods = artHook.getDexCacheResolvedMethods(); long hookDexCacheResolvedTypes = artHook.getDexCacheResolvedTypes(); long hookDexCodeItemOffset = artHook.getDexCodeItemOffset(); long hookDexMethodIndex = artHook.getDexMethodIndex(); ByteBuffer hookInfo = ByteBuffer.allocate(ART_HOOK_INFO_SIZE); hookInfo.putLong(originPointFromQuickCompiledCode); hookInfo.putLong(originEntryPointFromJni); hookInfo.putLong(originEntryPointFromInterpreter); hookInfo.putLong(originDeclaringClass); hookInfo.putLong(originAccessFlags); hookInfo.putLong(originDexCacheResolvedMethods); hookInfo.putLong(originDexCacheResolvedTypes); hookInfo.putLong(originDexCodeItemOffset); hookInfo.putLong(originDexMethodIndex); hookInfo.putLong(hookPointFromQuickCompiledCode); hookInfo.putLong(hookEntryPointFromJni); hookInfo.putLong(hookEntryPointFromInterpreter); hookInfo.putLong(hookDeclaringClass); hookInfo.putLong(hookAccessFlags); hookInfo.putLong(hookDexCacheResolvedMethods); hookInfo.putLong(hookDexCacheResolvedTypes); hookInfo.putLong(hookDexCodeItemOffset); hookInfo.putLong(hookDexMethodIndex); artOrigin.setEntryPointFromQuickCompiledCode(hookPointFromQuickCompiledCode); artOrigin.setEntryPointFromInterpreter(hookEntryPointFromInterpreter); artOrigin.setDeclaringClass(hookDeclaringClass); artOrigin.setDexCacheResolvedMethods(hookDexCacheResolvedMethods); artOrigin.setDexCacheResolvedTypes(hookDexCacheResolvedTypes); artOrigin.setDexCodeItemOffset((int) hookDexCodeItemOffset); artOrigin.setDexMethodIndex((int) hookDexMethodIndex); int accessFlags = origin.getModifiers(); if (Modifier.isNative(accessFlags)) { accessFlags &= ~Modifier.NATIVE; artOrigin.setAccessFlags(accessFlags); } long memoryAddress = Memory.alloc(ART_HOOK_INFO_SIZE); Memory.write(memoryAddress, hookInfo.array()); artOrigin.setEntryPointFromJni(memoryAddress); return backup; }
Example 12
Source File: Code.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
static boolean flagsRequireCode(int flags) { // A method's flags force it to have a Code attribute, // if the flags are neither native nor abstract. return (flags & (Modifier.NATIVE | Modifier.ABSTRACT)) == 0; }
Example 13
Source File: Code.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
static boolean flagsRequireCode(int flags) { // A method's flags force it to have a Code attribute, // if the flags are neither native nor abstract. return (flags & (Modifier.NATIVE | Modifier.ABSTRACT)) == 0; }
Example 14
Source File: Code.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
static boolean flagsRequireCode(int flags) { // A method's flags force it to have a Code attribute, // if the flags are neither native nor abstract. return (flags & (Modifier.NATIVE | Modifier.ABSTRACT)) == 0; }
Example 15
Source File: Code.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
static boolean flagsRequireCode(int flags) { // A method's flags force it to have a Code attribute, // if the flags are neither native nor abstract. return (flags & (Modifier.NATIVE | Modifier.ABSTRACT)) == 0; }
Example 16
Source File: AnnotationProcessor.java From rest.vertx with Apache License 2.0 | 4 votes |
private static boolean isNative(Method method) { return ((method.getModifiers() & Modifier.NATIVE) != 0); }
Example 17
Source File: JBBPDslBuilder.java From java-binary-block-parser with Apache License 2.0 | 4 votes |
/** * Allows to collect all fields which can be used for scripting. * * @param annotatedClass class to be processed, must not be null * @return container which contains all found items */ protected BinFieldContainer collectAnnotatedFields(final Class<?> annotatedClass) { final Bin defautBin = annotatedClass.getAnnotation(Bin.class); final BinFieldContainer result; if (defautBin != null) { result = new BinFieldContainer(annotatedClass, defautBin, true, null); } else { result = new BinFieldContainer(annotatedClass, null); } final Class<?> superclazz = annotatedClass.getSuperclass(); if (superclazz != null && superclazz != Object.class) { final BinFieldContainer parentFields = collectAnnotatedFields(superclazz); if (!parentFields.fields.isEmpty()) { result.addAllFromContainer(parentFields); } } for (final Field f : annotatedClass.getDeclaredFields()) { if ((f.getModifiers() & (Modifier.NATIVE | Modifier.STATIC | Modifier.FINAL | Modifier.PRIVATE | Modifier.TRANSIENT)) == 0) { final Bin foundFieldBin = f.getAnnotation(Bin.class); if (foundFieldBin != null || defautBin != null) { validateAnnotatedField(defautBin, foundFieldBin, f); final Class<?> type = f.getType().isArray() ? f.getType().getComponentType() : f.getType(); if (type.isPrimitive() || type == String.class) { if (foundFieldBin != null) { result.addBinField(foundFieldBin, true, f); } else { if (defautBin != null) { result.addBinField(defautBin, false, f); } } } else { final BinFieldContainer container = collectAnnotatedFields(type); if (!container.fields.isEmpty()) { if (foundFieldBin != null) { container.bin = foundFieldBin; container.fieldLocalAnnotation = true; } container.field = f; result.addContainer(container); } } } } } result.sort(); if (!result.fields.isEmpty()) { result.addContainer(BinFieldContainer.END_STRUCT); } return result; }
Example 18
Source File: AbstractMemberWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Return a string describing the access modifier flags. * Don't include native or synchronized. * * The modifier names are returned in canonical order, as * specified by <em>The Java Language Specification</em>. */ protected String modifierString(MemberDoc member) { int ms = member.modifierSpecifier(); int no = Modifier.NATIVE | Modifier.SYNCHRONIZED; return Modifier.toString(ms & ~no); }
Example 19
Source File: AbstractMemberWriter.java From openjdk-8-source with GNU General Public License v2.0 | 2 votes |
/** * Return a string describing the access modifier flags. * Don't include native or synchronized. * * The modifier names are returned in canonical order, as * specified by <em>The Java Language Specification</em>. */ protected String modifierString(MemberDoc member) { int ms = member.modifierSpecifier(); int no = Modifier.NATIVE | Modifier.SYNCHRONIZED; return Modifier.toString(ms & ~no); }
Example 20
Source File: AbstractMemberWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 2 votes |
/** * Return a string describing the access modifier flags. * Don't include native or synchronized. * * The modifier names are returned in canonical order, as * specified by <em>The Java Language Specification</em>. */ protected String modifierString(MemberDoc member) { int ms = member.modifierSpecifier(); int no = Modifier.NATIVE | Modifier.SYNCHRONIZED; return Modifier.toString(ms & ~no); }