Tabnine Logo
Modifier
Code IndexAdd Tabnine to your IDE (free)

How to use
Modifier
in
javassist

Best Java code snippets using javassist.Modifier (Showing top 20 results out of 873)

Refine searchRefine arrow

  • CtClass
  • CtMethod
  • MethodInfo
  • CannotCompileException
  • CtField
  • ClassPool
  • CtBehavior
origin: redisson/redisson

String name = m.getName();
if (m.getDeclaringClass() == clazz) {
  if (Modifier.isNative(mod))
    return;
  if (Modifier.isFinal(mod)) {
    mod &= ~Modifier.FINAL;
    m2.setModifiers(mod);
  if (Modifier.isFinal(mod))
    return;
  m2 = CtNewMethod.delegator(findOriginal(m, dontSearch), clazz);
  m2.setModifiers(mod);
  clazz.addMethod(m2);
       + "_" + name);
if (Modifier.isStatic(mod))
  body = trapStaticMethod;
else
             clazz);
wmethod.setModifiers(mod);
clazz.addMethod(wmethod);
origin: redisson/redisson

private CtClass produceProxyClass(CtClass orgclass, Class orgRtClass)
  throws CannotCompileException, NotFoundException
  int modify = orgclass.getModifiers();
  if (Modifier.isAbstract(modify) || Modifier.isNative(modify)
    || !Modifier.isPublic(modify))
    throw new CannotCompileException(orgclass.getName()
          + " must be public, non-native, and non-abstract.");
  CtClass proxy = classPool.makeClass(orgclass.getName(),
                     orgclass.getSuperclass());
    = new CtField(classPool.get("javassist.tools.rmi.ObjectImporter"),
           fieldImporter, proxy);
  f.setModifiers(Modifier.PRIVATE);
  proxy.addField(f, CtField.Initializer.byParameter(0));
  f = new CtField(CtClass.intType, fieldObjectId, proxy);
  f.setModifiers(Modifier.PRIVATE);
  proxy.addField(f, CtField.Initializer.byParameter(1)); 
    throw new CannotCompileException(e);
origin: redisson/redisson

public TransformCall(Transformer next, String oldMethodName,
           CtMethod substMethod)
{
  super(next);
  methodname = oldMethodName;
  methodDescriptor = substMethod.getMethodInfo2().getDescriptor();
  classname = newClassname = substMethod.getDeclaringClass().getName(); 
  newMethodname = substMethod.getName();
  constPool = null;
  newMethodIsPrivate = Modifier.isPrivate(substMethod.getModifiers());
}
origin: redisson/redisson

private void processMethods(CtClass clazz, boolean dontSearch)
  throws CannotCompileException, NotFoundException
{
  CtMethod[] ms = clazz.getMethods();
  for (int i = 0; i < ms.length; ++i) {
    CtMethod m = ms[i];
    int mod = m.getModifiers();
    if (Modifier.isPublic(mod) && !Modifier.isAbstract(mod))
      processMethods0(mod, clazz, m, i, dontSearch);
  }
}
origin: redisson/redisson

  private boolean isInheritable(int mod, CtClass superclazz) {
    if (Modifier.isPrivate(mod))
      return false;

    if (Modifier.isPackage(mod)) {
      String pname = getPackageName();
      String pname2 = superclazz.getPackageName();
      if (pname == null)
        return pname2 == null;
      else
        return pname.equals(pname2);
    }

    return true;
  }
}
origin: redisson/redisson

/**
 * Returns true if this member is accessible from the given class.
 */
public boolean visibleFrom(CtClass clazz) {
  int mod = getModifiers();
  if (Modifier.isPublic(mod))
    return true;
  else if (Modifier.isPrivate(mod))
    return clazz == declaringClass;
  else {  // package or protected
    String declName = declaringClass.getPackageName();
    String fromName = clazz.getPackageName();
    boolean visible;
    if (declName == null)
      visible = fromName == null;
    else
      visible = declName.equals(fromName);
    if (!visible && Modifier.isProtected(mod))
      return clazz.subclassOf(declaringClass);
    return visible;
  }
}
origin: redisson/redisson

public <T> Class<T> createStructClz( Class<T> clazz ) throws Exception {
  if ( Modifier.isFinal(clazz.getModifiers()) || Modifier.isAbstract(clazz.getModifiers()) ) {
    throw new RuntimeException("Cannot add final classes to structs "+clazz.getName());
    return present;
  ClassPool pool = defaultPool;
  CtClass newClz = pool.makeClass(proxyName);
  CtClass orig = null;
  if ( rawByteClassDefs.get(clazz.getName()) != null ) {
    orig = pool.makeClass( new ByteArrayInputStream(rawByteClassDefs.get(clazz.getName())));
  } else {
    orig = pool.getOrNull(clazz.getName());
    if ( orig == null ) {
      pool.insertClassPath(new ClassClassPath(clazz));
  newClz.setSuperclass(orig);
  CtMethod[] methods = orig.getMethods();
  for (int i = 0; i < methods.length; i++) {
    CtMethod method = methods[i];
    final Class curClz = Class.forName( method.getDeclaringClass().getName() );
    boolean allowed = ((method.getModifiers() & AccessFlag.ABSTRACT) == 0 ) &&
        (method.getModifiers() & AccessFlag.NATIVE) == 0 &&
        (method.getModifiers() & AccessFlag.FINAL) == 0 &&
        (   !method.getDeclaringClass().getName().equals(FSTStruct.class.getName())
origin: apache/incubator-dubbo

public Class<?> toClass(ClassLoader loader, ProtectionDomain pd) {
  if (mCtc != null) {
    mCtc.detach();
    CtClass ctcs = mSuperClass == null ? null : mPool.get(mSuperClass);
    if (mClassName == null) {
      mClassName = (mSuperClass == null || javassist.Modifier.isPublic(ctcs.getModifiers())
          ? ClassGenerator.class.getName() : mSuperClass + "$sc") + id;
    mCtc = mPool.makeClass(mClassName);
    if (mSuperClass != null) {
      mCtc.setSuperclass(ctcs);
    mCtc.addInterface(mPool.get(DC.class.getName())); // add dynamic class tag.
    if (mInterfaces != null) {
      for (String cl : mInterfaces) {
        mCtc.addField(CtField.make(code, mCtc));
    throw new RuntimeException(e.getMessage(), e);
  } catch (CannotCompileException e) {
    throw new RuntimeException(e.getMessage(), e);
origin: changmingxie/tcc-transaction

public Class<?> toClass() {
  if (mCtc != null)
    mCtc.detach();
  long id = CLASS_NAME_COUNTER.getAndIncrement();
  try {
    CtClass ctcs = mSuperClass == null ? null : mPool.get(mSuperClass);
    if (mClassName == null)
      mClassName = (mSuperClass == null || javassist.Modifier.isPublic(ctcs.getModifiers())
          ? TccClassGenerator.class.getName() : mSuperClass + "$sc") + id;
    mCtc = mPool.makeClass(mClassName);
    if (mSuperClass != null)
      mCtc.setSuperclass(ctcs);
    mCtc.addInterface(mPool.get(DC.class.getName())); // add dynamic class tag.
    if (mInterfaces != null)
      for (String cl : mInterfaces) mCtc.addInterface(mPool.get(cl));
    if (mFields != null)
      for (String code : mFields) mCtc.addField(CtField.make(code, mCtc));
    if (mMethods != null) {
      for (String code : mMethods) {
            ctMethod.getMethodInfo().addAttribute(attr);
    throw new RuntimeException(e.getMessage(), e);
  } catch (CannotCompileException e) {
    throw new RuntimeException(e.getMessage(), e);
origin: apache/incubator-dubbo

} catch (ClassNotFoundException e) {
  ClassPool pool = ClassGenerator.getClassPool(clazz.getClassLoader());
  CtClass ctClass = pool.makeClass(parameterClassName);
  ClassFile classFile = ctClass.getClassFile();
  classFile.setVersionToJava5();
  ctClass.addConstructor(CtNewConstructor.defaultConstructor(pool.getCtClass(parameterClassName)));
      if (annotation.annotationType().isAnnotationPresent(Constraint.class)) {
        javassist.bytecode.annotation.Annotation ja = new javassist.bytecode.annotation.Annotation(
            classFile.getConstPool(), pool.getCtClass(annotation.annotationType().getName()));
        Method[] members = annotation.annotationType().getMethods();
        for (Method member : members) {
          if (Modifier.isPublic(member.getModifiers())
              && member.getParameterTypes().length == 0
              && member.getDeclaringClass() == annotation.annotationType()) {
    CtField ctField = CtField.make("public " + type.getCanonicalName() + " " + fieldName + ";", pool.getCtClass(parameterClassName));
    ctField.getFieldInfo().addAttribute(attribute);
    ctClass.addField(ctField);
  parameterClass = ctClass.toClass(clazz.getClassLoader(), null);
origin: javalite/activejdbc

private void doInstrument(CtClass target) throws NotFoundException, CannotCompileException {
  CtMethod[] modelMethods = modelClass.getDeclaredMethods();
  CtMethod[] targetMethods = target.getDeclaredMethods();
  CtMethod modelGetClass = modelClass.getDeclaredMethod("modelClass");
  CtMethod newGetClass = CtNewMethod.copy(modelGetClass, target, null);
  newGetClass.setBody("{ return " + target.getName() + ".class; }");
    int modifiers = method.getModifiers();
    if (Modifier.isStatic(modifiers)) {
      if (targetHasMethod(targetMethods, method)) {
        Logger.debug("Detected method: " + method.getName() + ", skipping delegate.");
      } else {
        CtMethod newMethod;
        if (Modifier.isProtected(modifiers) || Modifier.isPublic(modifiers)) {
          newMethod = CtNewMethod.copy(method, target, classMap);
          newMethod.instrument(conv);
        for (Object attr : method.getMethodInfo().getAttributes()) {
          if (attr instanceof SignatureAttribute) {
            newMethod.getMethodInfo().addAttribute((SignatureAttribute) attr);
origin: rapidoid/rapidoid

  ClassPool cp = new ClassPool();
  cp.insertClassPath(new ClassClassPath(method.getDeclaringClass()));
  CtClass cc = cp.get(method.getDeclaringClass().getName());
  useIndexMapping = cc.getClassFile().getMajorVersion() >= 52;
  cm = cc.getDeclaredMethod(method.getName(), params);
MethodInfo methodInfo = cm.getMethodInfo();
CodeAttribute codeAttribute = methodInfo.getCodeAttribute();
    .getAttribute(LocalVariableAttribute.tag);
  int offset = Modifier.isStatic(cm.getModifiers()) ? 0 : 1;
origin: 58code/Argo

ClassPool pool = ClassPool.getDefault();
pool.insertClassPath(new ClassClassPath(clazz));
CtClass cc = pool.get(clazz.getName());
  paramTypeNames[i] = paramTypes[i].getName();
CtMethod cm = cc.getDeclaredMethod(method.getName(), pool.get(paramTypeNames));
MethodInfo methodInfo = cm.getMethodInfo();
CodeAttribute codeAttribute = methodInfo.getCodeAttribute();
LocalVariableAttribute attr = (LocalVariableAttribute) codeAttribute
    .getAttribute(LocalVariableAttribute.tag);
String[] paramNames = new String[cm.getParameterTypes().length];
int pos = Modifier.isStatic(cm.getModifiers()) ? 0 : 1;
origin: fabric8io/fabric8-maven-plugin

private static boolean hasMainMethod(InputStream is) throws IOException {
  try {
    ClassPool pool = ClassPool.getDefault();
    CtClass ctClass = pool.makeClass(is);
    CtClass stringClass = pool.get("java.lang.String[]");
    CtMethod mainMethod = ctClass.getDeclaredMethod("main", new CtClass[] { stringClass });
    return mainMethod.getReturnType() == CtClass.voidType &&
        Modifier.isStatic(mainMethod.getModifiers()) &&
        Modifier.isPublic(mainMethod.getModifiers());
  } catch (NotFoundException e) {
    return false;
  }
}
origin: h2oai/h2o-2

private void ensureType(CtClass cc) throws NotFoundException, CannotCompileException {
 CtMethod ccms[] = cc.getDeclaredMethods();
 if( !javassist.Modifier.isAbstract(cc.getModifiers()) &&
   !hasExisting("frozenType", "()I", ccms) ) {
  // Build a simple field & method returning the type token
  cc.addField(new CtField(CtClass.intType, "_frozen$type", cc));
  cc.addMethod(CtNewMethod.make("public int frozenType() {" +
                 "  return _frozen$type == 0 ? (_frozen$type=water.TypeMap.onIce(\""+cc.getName()+"\")) : _frozen$type;" +
                 "}",cc));
 }
}
origin: redisson/redisson

private static CtMethod delegator0(CtMethod delegate, CtClass declaring)
  throws CannotCompileException, NotFoundException
  MethodInfo deleInfo = delegate.getMethodInfo2();
  String methodName = deleInfo.getName();
  String desc = deleInfo.getDescriptor();
  ConstPool cp = declaring.getClassFile2().getConstPool();
  MethodInfo minfo = new MethodInfo(cp, methodName, desc);
  minfo.setAccessFlags(deleInfo.getAccessFlags());
  boolean isStatic = Modifier.isStatic(delegate.getModifiers());
  CtClass deleClass = delegate.getDeclaringClass();
  CtClass[] params = delegate.getParameterTypes();
  int s;
origin: hibernate/hibernate-orm

private CtField[] collectPersistentFields(CtClass managedCtClass) {
  List<CtField> persistentFieldList = new ArrayList<CtField>();
  for ( CtField ctField : managedCtClass.getDeclaredFields() ) {
    // skip static fields and skip fields added by enhancement and  outer reference in inner classes
    if ( ctField.getName().startsWith( "$$_hibernate_" ) || "this$0".equals( ctField.getName() ) ) {
      continue;
    }
    if ( !Modifier.isStatic( ctField.getModifiers() ) && enhancementContext.isPersistentField( ctField ) ) {
      persistentFieldList.add( ctField );
    }
  }
  // HHH-10646 Add fields inherited from @MappedSuperclass
  // HHH-10981 There is no need to do it for @MappedSuperclass
  if ( !enhancementContext.isMappedSuperclassClass( managedCtClass ) ) {
    persistentFieldList.addAll( collectInheritPersistentFields( managedCtClass ) );
  }
  CtField[] orderedFields = enhancementContext.order( persistentFieldList.toArray( new CtField[0] ) );
  log.debugf( "Persistent fields for entity %s: %s", managedCtClass.getName(), Arrays.toString( orderedFields ) );
  return orderedFields;
}
origin: redisson/redisson

cc.checkModify();
CodeAttribute ca = methodInfo.getCodeAttribute();
if (ca == null)
  throw new CannotCompileException("no method body");
  int nvars = jv.recordParams(getParameterTypes(),
                Modifier.isStatic(getModifiers()));
  jv.recordParamNames(ca, nvars);
  jv.recordLocalVariables(ca, 0);
  jv.recordType(getReturnType0());
  jv.compileStmnt(src);
  Bytecode b = jv.getBytecode();
  iterator.insert(b.getExceptionTable(), pos);
  if (rebuild)
    methodInfo.rebuildStackMapIf6(cc.getClassPool(), cc.getClassFile2());
  throw new CannotCompileException(e);
  throw new CannotCompileException(e);
origin: h2oai/h2o-2

private void ensureNewInstance(CtClass cc) throws NotFoundException, CannotCompileException {
 CtMethod ccms[] = cc.getDeclaredMethods();
 if( !javassist.Modifier.isAbstract(cc.getModifiers()) &&
   !hasExisting("newInstance", "()Lwater/Freezable;", ccms) ) {
  cc.addMethod(CtNewMethod.make(
    "public water.Freezable newInstance() {\n" +
    "    return new " +cc.getName()+"();\n" +
    "}", cc));
 }
}
origin: redisson/redisson

int mod = m.getModifiers();
if (m.getDeclaringClass() != Object.class
      && !Modifier.isFinal(mod))
  if (Modifier.isPublic(mod)) {
    CtMethod body;
    if (Modifier.isStatic(mod))
      body = forwardStaticMethod;
    else
                 ConstParameter.integer(i),
                 proxy);
    wmethod.setModifiers(mod);
    proxy.addMethod(wmethod);
  else if (!Modifier.isProtected(mod)
       && !Modifier.isPrivate(mod))
    throw new CannotCompileException(
      "the methods must be public, protected, or private.");
javassistModifier

Javadoc

The Modifier class provides static methods and constants to decode class and member access modifiers. The constant values are equivalent to the corresponding values in javassist.bytecode.AccessFlag.

All the methods/constants in this class are compatible with ones in java.lang.reflect.Modifier.

Most used methods

  • isStatic
    Returns true if the modifiers include the static modifier.
  • isPublic
    Returns true if the modifiers include the public modifier.
  • isAbstract
    Returns true if the modifiers include the abstract modifier.
  • isFinal
    Returns true if the modifiers include the final modifier.
  • isPrivate
    Returns true if the modifiers include the private modifier.
  • isProtected
    Returns true if the modifiers include the protected modifier.
  • isNative
    Returns true if the modifiers include the native modifier.
  • setPublic
    Truns the public bit on. The protected and private bits are cleared.
  • toString
    Return a string describing the access modifier flags in the specified modifier.
  • isInterface
    Returns true if the modifiers include the interface modifier.
  • isEnum
    Returns true if the modifiers include the enum modifier.
  • isPackage
    Returns true if the modifiers do not include eitherpublic, protected, or private .
  • isEnum,
  • isPackage,
  • isAnnotation,
  • isTransient,
  • clear,
  • setProtected,
  • isSynchronized,
  • setPrivate,
  • isVolatile,
  • setPackage

Popular in Java

  • Start an intent from android
  • compareTo (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • notifyDataSetChanged (ArrayAdapter)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now