本文整理汇总了Java中java.lang.reflect.Modifier.isStatic方法的典型用法代码示例。如果您正苦于以下问题:Java Modifier.isStatic方法的具体用法?Java Modifier.isStatic怎么用?Java Modifier.isStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.reflect.Modifier
的用法示例。
在下文中一共展示了Modifier.isStatic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStaticAccess
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
@NonNull
private ArrayList<Description> getStaticAccess(String className) {
ClassDescription classDescription = mClassLoader.getClassReader().readClassByName(className, null);
ArrayList<Description> result = new ArrayList<>();
if (classDescription != null) {
for (FieldDescription fieldDescription : classDescription.getFields()) {
if (Modifier.isStatic(fieldDescription.getModifiers())
&& Modifier.isPublic(fieldDescription.getModifiers())) {
result.add(fieldDescription);
}
}
for (MethodDescription methodDescription : classDescription.getMethods()) {
if (Modifier.isStatic(methodDescription.getModifiers())
&& Modifier.isPublic(methodDescription.getModifiers())) {
result.add(methodDescription);
}
}
}
return result;
}
示例2: fields
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* 取得一个Map,map中的key为字段名,value为字段对应的反射工具类
*
* @return Map
*/
public Map<String, Reflect> fields() {
Map<String, Reflect> result = new LinkedHashMap<String, Reflect>();
Class<?> type = type();
do {
for (Field field : type.getDeclaredFields()) {
if (!isClass ^ Modifier.isStatic(field.getModifiers())) {
String name = field.getName();
if (!result.containsKey(name))
result.put(name, field(name));
}
}
type = type.getSuperclass();
} while (type != null);
return result;
}
示例3: documentField
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private static void documentField(PrintStream stream, Field field) {
stream.print("** [[");
emitAnchor(stream, field);
stream.print("]]");
if (Modifier.isStatic(field.modifiers)) {
stream.print("static ");
}
emitType(stream, field.type);
stream.print(' ');
String javadocRoot = javadocRoot(field);
emitJavadocLink(stream, javadocRoot, field);
stream.print('[');
stream.print(field.name);
stream.print(']');
if (javadocRoot.equals("java8")) {
stream.print(" (");
emitJavadocLink(stream, "java9", field);
stream.print("[java 9])");
}
stream.println();
}
示例4: BytecoderUnitTestRunner
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public BytecoderUnitTestRunner(Class aClass) throws InitializationError {
super(aClass);
testClass = new TestClass(aClass);
testMethods = new ArrayList<>();
Method[] classMethods = aClass.getDeclaredMethods();
for (Method classMethod : classMethods) {
Class retClass = classMethod.getReturnType();
int length = classMethod.getParameterTypes().length;
int modifiers = classMethod.getModifiers();
if (retClass == null || length != 0 || Modifier.isStatic(modifiers)
|| !Modifier.isPublic(modifiers) || Modifier.isInterface(modifiers)
|| Modifier.isAbstract(modifiers)) {
continue;
}
String methodName = classMethod.getName();
if (methodName.toUpperCase().startsWith("TEST")
|| classMethod.getAnnotation(Test.class) != null) {
testMethods.add(new FrameworkMethod(classMethod));
}
if (classMethod.getAnnotation(Ignore.class) != null) {
testMethods.remove(classMethod);
}
}
}
示例5: start
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private void start() throws Throwable {
do {
if ((this.method != null) && Modifier.isStatic(this.method.getModifiers())) {
run(); // invoke static method on the current thread
}
else {
SwingUtilities.invokeLater(this); // invoke on the event dispatch thread
}
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
SunToolkit stk = (SunToolkit) tk;
stk.realSync(); // wait until done
}
}
while (this.frame != null);
if (this.error != null) {
throw this.error;
}
}
示例6: shouldIncludeGetter
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private static boolean shouldIncludeGetter(Method method) {
if (!method.getName().startsWith("get") && !method.getName().startsWith("is")) {
return false;
}
// Exclude methods from Object.class
if (method.getDeclaringClass().equals(Object.class)) {
return false;
}
// Non-public methods
if (!Modifier.isPublic(method.getModifiers())) {
return false;
}
// Static methods
if (Modifier.isStatic(method.getModifiers())) {
return false;
}
// No return type
if (method.getReturnType().equals(Void.TYPE)) {
return false;
}
// Non-zero parameters
if (method.getParameterTypes().length != 0) {
return false;
}
// Excluded methods
if (method.isAnnotationPresent(Exclude.class)) {
return false;
}
return true;
}
示例7: visitMethod
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private MethodCollector visitMethod(int access, String name, String desc) {
// already found the method, skip any processing
if (collector != null) {
return null;
}
// not the same name
if (!name.equals(methodName)) {
return null;
}
Type[] argumentTypes = Type.getArgumentTypes(desc);
int longOrDoubleQuantity = 0;
for (Type t : argumentTypes) {
if (t.getClassName().equals("long")
|| t.getClassName().equals("double")) {
longOrDoubleQuantity++;
}
}
int paramCount = argumentTypes.length;
// not the same quantity of parameters
if (paramCount != this.parameterTypes.length) {
return null;
}
for (int i = 0; i < argumentTypes.length; i++) {
if (!correctTypeName(argumentTypes, i).equals(
this.parameterTypes[i].getName())) {
return null;
}
}
this.collector = new MethodCollector((Modifier.isStatic(access) ? 0 : 1),
argumentTypes.length + longOrDoubleQuantity);
return collector;
}
示例8: getValueOfMethod
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static Method getValueOfMethod(Class type) {
try {
Method method = type.getDeclaredMethod("valueOf", String.class);
if (method == null || !Modifier.isStatic(method.getModifiers())) {
return null;
}
return method;
} catch (Exception e) {
return null;
}
}
示例9: initializeStaticFinalFields
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public static List<Object> initializeStaticFinalFields(Class<?> klass) {
List<Object> result = new ArrayList<Object>();
for (Field f : klass.getDeclaredFields()) {
if (Modifier.isStatic(f.getModifiers()) && Modifier.isFinal(f.getModifiers())) {
try {
f.setAccessible(true);
result.add(f.get(null));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
return result;
}
示例10: validateInputs
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private void validateInputs(Object proxy, Method method) {
if (proxy == null || !Proxy.isProxyClass(proxy.getClass())) {
throw new IllegalStateException("Passed object is not proxy!");
}
if (method == null || method.getDeclaringClass() == null
|| Modifier.isStatic(method.getModifiers())) {
throw new IllegalStateException("Invoking static method is not allowed!");
}
}
示例11: isExtensionMethod
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
private boolean isExtensionMethod( AbstractSrcMethod method, String extendedType )
{
if( !Modifier.isStatic( (int)method.getModifiers() ) || Modifier.isPrivate( (int)method.getModifiers() ) )
{
return false;
}
if( method.hasAnnotation( Extension.class ) )
{
return true;
}
return hasThisAnnotation( method, extendedType );
}
示例12: registerMethod
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
/**
* Register a method, the method must be static
*/
public static void registerMethod(String name, Method method) {
name = name.toLowerCase();
if (methodMap.containsKey(name)) {
throw new IllegalArgumentException("duplicated method name");
}
if (!Modifier.isStatic(method.getModifiers())) {
throw new IllegalArgumentException("method not static");
}
methodMap.put(name, method);
}
示例13: ClassSizeInfo
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
public ClassSizeInfo(final Class<?> clazz) {
long newFieldsSize = 0;
final List<Field> newReferenceFields = new LinkedList<>();
for (final Field f : clazz.getDeclaredFields()) {
if (Modifier.isStatic(f.getModifiers())) {
continue;
}
final Class<?> type = f.getType();
if (type.isPrimitive()) {
newFieldsSize += getPrimitiveFieldSize(type);
} else {
f.setAccessible(true);
newReferenceFields.add(f);
newFieldsSize += referenceSize;
}
}
final Class<?> superClass = clazz.getSuperclass();
if (superClass != null) {
final ClassSizeInfo superClassInfo = getClassSizeInfo(superClass);
newFieldsSize += roundTo(superClassInfo.fieldsSize, superclassFieldPadding);
newReferenceFields.addAll(Arrays.asList(superClassInfo.referenceFields));
}
this.fieldsSize = newFieldsSize;
this.objectSize = roundTo(objectHeaderSize + newFieldsSize, objectPadding);
this.referenceFields = newReferenceFields.toArray(
new Field[newReferenceFields.size()]);
}
示例14: getTarget
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
@Override
MethodHandle getTarget(final MethodHandles.Lookup lookup) {
if(target instanceof Method) {
final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
if(Modifier.isStatic(((Member)target).getModifiers())) {
return StaticClassIntrospector.editStaticMethodHandle(mh);
}
return mh;
}
return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructor(lookup,
(Constructor<?>)target));
}
示例15: matches
import java.lang.reflect.Modifier; //导入方法依赖的package包/类
@Override
public boolean matches(Field field) {
return !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers()));
}