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


Java Modifier.PUBLIC属性代码示例

本文整理汇总了Java中java.lang.reflect.Modifier.PUBLIC属性的典型用法代码示例。如果您正苦于以下问题:Java Modifier.PUBLIC属性的具体用法?Java Modifier.PUBLIC怎么用?Java Modifier.PUBLIC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.lang.reflect.Modifier的用法示例。


在下文中一共展示了Modifier.PUBLIC属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSerializableConstructor

/**
 * Returns subclass-accessible no-arg constructor of first non-serializable
 * superclass, or null if none found.  Access checks are disabled on the
 * returned constructor (if any).
 */
private static Constructor<?> getSerializableConstructor(Class<?> cl) {
    Class<?> initCl = cl;
    while (Serializable.class.isAssignableFrom(initCl)) {
        if ((initCl = initCl.getSuperclass()) == null) {
            return null;
        }
    }
    try {
        Constructor<?> cons = initCl.getDeclaredConstructor((Class<?>[]) null);
        int mods = cons.getModifiers();
        if ((mods & Modifier.PRIVATE) != 0 ||
            ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 &&
             !packageEquals(cl, initCl)))
        {
            return null;
        }
        cons = reflFactory.newConstructorForSerialization(cl, cons);
        cons.setAccessible(true);
        return cons;
    } catch (NoSuchMethodException ex) {
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:ObjectStreamClass.java

示例2: reflectProperties

private static Property[] reflectProperties(Class<? extends AbstractDao<?, ?>> daoClass)
        throws ClassNotFoundException, IllegalArgumentException, IllegalAccessException {
    Class<?> propertiesClass = Class.forName(daoClass.getName() + "$Properties");
    Field[] fields = propertiesClass.getDeclaredFields();

    ArrayList<Property> propertyList = new ArrayList<Property>();
    final int modifierMask = Modifier.STATIC | Modifier.PUBLIC;
    for (Field field : fields) {
        // There might be other fields introduced by some tools, just ignore them (see issue #28)
        if ((field.getModifiers() & modifierMask) == modifierMask) {
            Object fieldValue = field.get(null);
            if (fieldValue instanceof Property) {
                propertyList.add((Property) fieldValue);
            }
        }
    }

    Property[] properties = new Property[propertyList.size()];
    for (Property property : propertyList) {
        if (properties[property.ordinal] != null) {
            throw new DaoException("Duplicate property ordinals");
        }
        properties[property.ordinal] = property;
    }
    return properties;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:DaoConfig.java

示例3: getSetMethod

/**
 * @param type
 * @param name
 * @return Method
 */
public static Method getSetMethod(Class<?> type, String name) {
    Method[] methods = type.getMethods();
    String methodName = "set" + Character.toUpperCase(name.charAt(0)) + name.substring(1);

    for(Method method : methods) {
        if(method.getModifiers() != Modifier.PUBLIC) {
            continue;
        }

        if(method.getName().equals(methodName)) {
            if(method.getParameterTypes().length == 1) {
                return method;
            }
        }
    }
    return null;
}
 
开发者ID:jeffreyning,项目名称:nh-micro,代码行数:22,代码来源:ClassUtil.java

示例4: getInheritableMethod

/**
 * Returns non-static, non-abstract method with given signature provided it
 * is defined by or accessible (via inheritance) by the given class, or
 * null if no match found.  Access checks are disabled on the returned
 * method (if any).
 */
private static Method getInheritableMethod(Class<?> cl, String name,
                                           Class<?>[] argTypes,
                                           Class<?> returnType)
{
    Method meth = null;
    Class<?> defCl = cl;
    while (defCl != null) {
        try {
            meth = defCl.getDeclaredMethod(name, argTypes);
            break;
        } catch (NoSuchMethodException ex) {
            defCl = defCl.getSuperclass();
        }
    }

    if ((meth == null) || (meth.getReturnType() != returnType)) {
        return null;
    }
    meth.setAccessible(true);
    int mods = meth.getModifiers();
    if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) {
        return null;
    } else if ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0) {
        return meth;
    } else if ((mods & Modifier.PRIVATE) != 0) {
        return (cl == defCl) ? meth : null;
    } else {
        return packageEquals(cl, defCl) ? meth : null;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:ObjectStreamClass.java

示例5: isUsableCustomLayoutClass

private static boolean isUsableCustomLayoutClass(Class layoutClass) {
    if ((layoutClass.getModifiers() & Modifier.PUBLIC) == 0) {
        return false;
    }
    try {
        if (layoutClass.getConstructor(new Class[0]) != null) {
            return true; // has a public constructor without parameters
        }
    } catch (NoSuchMethodException ex) {
    }
    return CreationFactory.getDescriptor(layoutClass) != null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:LayoutSupportRegistry.java

示例6: resolveProxyClass

/**
 * ObjectInputStream.resolveProxyClass has some funky way of using 
 * the incorrect class loader to resolve proxy classes, let's do it our way instead
 */
@Override
protected Class<?> resolveProxyClass(String[] interfaces)
        throws IOException, ClassNotFoundException {
    
    ClassLoader latestLoader;
    if (classLoaders != null && classLoaders.length > 0) {
        latestLoader = classLoaders[0];
    } else {
        latestLoader = null;
    }
    ClassLoader nonPublicLoader = null;
    boolean hasNonPublicInterface = false;

    // define proxy in class loader of non-public interface(s), if any
    Class<?>[] classObjs = new Class[interfaces.length];
    for (int i = 0; i < interfaces.length; i++) {
        Class<?> cl = this.resolveClass(interfaces[i]);
        if (latestLoader==null) latestLoader = cl.getClassLoader();
        if ((cl.getModifiers() & Modifier.PUBLIC) == 0) {
            if (hasNonPublicInterface) {
                if (nonPublicLoader != cl.getClassLoader()) {
                    throw new IllegalAccessError(
                            "conflicting non-public interface class loaders");
                }
            } else {
                nonPublicLoader = cl.getClassLoader();
                hasNonPublicInterface = true;
            }
        }
        classObjs[i] = cl;
    }
    try {
        return Proxy.getProxyClass(hasNonPublicInterface ? nonPublicLoader
                : latestLoader, classObjs);
    } catch (IllegalArgumentException e) {
        throw new ClassNotFoundException(null, e);
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:42,代码来源:ReplicationStream.java

示例7: findClickMethods

private void findClickMethods(Method[] methods) {
    for (Method method : methods) {
        String methodName = method.getName();
        if (!methodName.equals(ON_CLICK_METHOD_NAME) && methodName.startsWith(ON_CLICK_METHOD_NAME) ||
                (methodName.startsWith(ON_CLICK_METHOD_PREFIX) && methodName.endsWith(ON_CLICK_METHOD_POSTFIX))) {
            int modifiers = method.getModifiers();
            if ((modifiers & Modifier.PUBLIC) != 0 && (modifiers & MODIFIERS_IGNORE) == 0) {
                Class<?>[] parameterTypes = method.getParameterTypes();
                if (parameterTypes.length == 3 || parameterTypes.length == 4) {
                    Class<?> viewType = parameterTypes[0];
                    Class<?> cellType = parameterTypes[1];
                    Class<?> clickIntType = parameterTypes[2];
                    if (View.class.isAssignableFrom(viewType)
                            && BaseCell.class.isAssignableFrom(cellType)
                            && (clickIntType.equals(int.class) || clickIntType.equals(Integer.class))) {
                        if (parameterTypes.length == 4) {
                            Class<?> clickParamsType = parameterTypes[3];
                            if (Map.class.isAssignableFrom(clickParamsType)) {
                                mOnClickMethods.put(viewType, new OnClickMethod(4, method));
                            }
                        } else {
                            mOnClickMethods.put(viewType, new OnClickMethod(3, method));
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:alibaba,项目名称:Tangram-Android,代码行数:29,代码来源:SimpleClickSupport.java

示例8: resolveProxyClass

@Override
protected Class resolveProxyClass(String[] interfaces)
    throws IOException, ClassNotFoundException {

  ClassLoader nonPublicLoader = null;
  boolean hasNonPublicInterface = false;

  // define proxy in class loader of non-public
  // interface(s), if any
  Class[] classObjs = new Class[interfaces.length];
  for (int i = 0; i < interfaces.length; i++) {
    Class cl = getCachedClass(interfaces[i]);
    if ((cl.getModifiers() & Modifier.PUBLIC) == 0) {
      if (hasNonPublicInterface) {
        if (nonPublicLoader != cl.getClassLoader()) {
          String s = "conflicting non-public interface class loaders";
          throw new IllegalAccessError(s);
        }

      } else {
        nonPublicLoader = cl.getClassLoader();
        hasNonPublicInterface = true;
      }
    }
    classObjs[i] = cl;
  }

  try {
    if (hasNonPublicInterface) {
      return Proxy.getProxyClass(nonPublicLoader, classObjs);
    } else {
      return ClassPathLoader.getLatest().getProxyClass(classObjs);
    }
  } catch (IllegalArgumentException e) {
    throw new ClassNotFoundException(null, e);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:37,代码来源:InternalDataSerializer.java

示例9: generateConstructors

private boolean generateConstructors() throws AdaptationException {
    boolean gotCtor = false;
    boolean canBeAutoConverted = false;
    for (final Constructor<?> ctor: superClass.getDeclaredConstructors()) {
        final int modifier = ctor.getModifiers();
        if((modifier & (Modifier.PUBLIC | Modifier.PROTECTED)) != 0 && !isCallerSensitive(ctor)) {
            canBeAutoConverted = generateConstructors(ctor) | canBeAutoConverted;
            gotCtor = true;
        }
    }
    if(!gotCtor) {
        throw new AdaptationException(ERROR_NO_ACCESSIBLE_CONSTRUCTOR, superClass.getCanonicalName());
    }
    return canBeAutoConverted;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:JavaAdapterBytecodeGenerator.java

示例10: createJava

public static String createJava(String zpackage, String name, int kind, int visibility, int modifier, boolean b) {
    String m = "";
    switch (modifier) {
        case Modifier.ABSTRACT:
            m = "abstract ";
            break;
        case Modifier.FINAL:
            m = "final ";
            break;
    }
    String v = "";
    switch (visibility) {
        case Modifier.PUBLIC:
            v = "public ";
            break;
    }
    String k = "class";
    switch (kind) {
        case 0:
            k = "class";
            break;
        case 1:
            k = "interface";
            break;
        case 2:
            k = "enum";
            break;
    }
    zpackage = zpackage.isEmpty() ? "" : "package " + zpackage + ";";

    return String.format(JAVA_TEMPLATE, v, m, k, name, zpackage);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:32,代码来源:Template.java

示例11: getMapperMethodsByClazz

private static void getMapperMethodsByClazz(final List<Method> result, final Class clazz) {
    if (clazz != null && clazz.isAnnotationPresent(LuaViewLib.class)) {//XXXMapper
        getMapperMethodsByClazz(result, clazz.getSuperclass());//处理super
        final Method[] methods = clazz.getDeclaredMethods();
        if (methods != null && methods.length > 0) {
            for (final Method method : methods) {//add self
                if (method.getModifiers() == Modifier.PUBLIC) {//public 方法才行
                    result.add(method);
                }
            }
        }
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:13,代码来源:LuaViewManager.java

示例12: translateModifiers

/**
 * 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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:DocEnv.java

示例13: resolveProxyClass

protected Class<?> resolveProxyClass(String[] interfaces) throws
       IOException, ClassNotFoundException {
    ClassLoader nonPublicLoader = null;
    boolean hasNonPublicInterface = false;

    // define proxy in class loader of non-public interface(s), if any
    Class<?>[] classObjs = new Class<?>[interfaces.length];
    for (int i = 0; i < interfaces.length; i++) {
        Class<?> cl = Class.forName(interfaces[i], false, classLoader);
        if ((cl.getModifiers() & Modifier.PUBLIC) == 0) {
            if (hasNonPublicInterface) {
                if (nonPublicLoader != cl.getClassLoader()) {
                    throw new IllegalAccessError(
                       "conflicting non-public interface class loaders");
                }
            } else {
                nonPublicLoader = cl.getClassLoader();
                hasNonPublicInterface = true;
            }
        }
        classObjs[i] = cl;
    }
    try {
        return Proxy.getProxyClass(hasNonPublicInterface ?
               nonPublicLoader : classLoader, classObjs);
    } catch (IllegalArgumentException e) {
        throw new ClassNotFoundException(null, e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:Obj.java

示例14: isPublic

private boolean isPublic(Class<?> keyHandlerType)
{
	return keyHandlerType.getModifiers() == Modifier.PUBLIC;
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:4,代码来源:KeyHandlerFactory.java

示例15: getModifiers

public static long getModifiers( PsiModifierList modifierList )
{
  long modifiers = 0;
  if( modifierList.hasExplicitModifier( PsiModifier.ABSTRACT ) )
  {
    modifiers |= Modifier.ABSTRACT;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.DEFAULT ) )
  {
    modifiers |= 0x80000000000L; //Flags.DEFAULT;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.FINAL ) )
  {
    modifiers |= Modifier.FINAL;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.PRIVATE ) )
  {
    modifiers |= Modifier.PRIVATE;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.PROTECTED ) )
  {
    modifiers |= Modifier.PROTECTED;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.PUBLIC ) )
  {
    modifiers |= Modifier.PUBLIC;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.STATIC ) )
  {
    modifiers |= Modifier.STATIC;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.SYNCHRONIZED ) )
  {
    modifiers |= Modifier.SYNCHRONIZED;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.TRANSIENT ) )
  {
    modifiers |= Modifier.TRANSIENT;
  }
  if( modifierList.hasExplicitModifier( PsiModifier.VOLATILE ) )
  {
    modifiers |= Modifier.VOLATILE;
  }
  return modifiers;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:45,代码来源:StubBuilder.java


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