当前位置: 首页>>代码示例>>Java>>正文


Java Modifier.isStatic方法代码示例

本文整理汇总了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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:21,代码来源:AutoCompleteProvider.java

示例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;
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:25,代码来源:Reflect.java

示例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();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:PainlessDocGenerator.java

示例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);
        }
    }
}
 
开发者ID:mirkosertic,项目名称:Bytecoder,代码行数:26,代码来源:BytecoderUnitTestRunner.java

示例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;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:SwingTest.java

示例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;
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:31,代码来源:CustomClassMapper.java

示例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;
}
 
开发者ID:Yoio,项目名称:X4J,代码行数:33,代码来源:BytecodeReadingParanamer.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:Util.java

示例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;
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:15,代码来源:ReflectionUtils.java

示例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!");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:SEIStub.java

示例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 );
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:15,代码来源:ManAugmentProvider.java

示例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);
}
 
开发者ID:NyaaCat,项目名称:NyaaCore,代码行数:14,代码来源:IPCUtils.java

示例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()]);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:ObjectSizeCalculator.java

示例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));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:CallerSensitiveDynamicMethod.java

示例15: matches

import java.lang.reflect.Modifier; //导入方法依赖的package包/类
@Override
public boolean matches(Field field) {
	return !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers()));
}
 
开发者ID:drinkjava2,项目名称:jDialects,代码行数:5,代码来源:ReflectionUtils.java


注:本文中的java.lang.reflect.Modifier.isStatic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。