Tabnine Logo
ClassWriter.visitMethod
Code IndexAdd Tabnine to your IDE (free)

How to use
visitMethod
method
in
jersey.repackaged.org.objectweb.asm.ClassWriter

Best Java code snippets using jersey.repackaged.org.objectweb.asm.ClassWriter.visitMethod (Showing top 3 results out of 315)

origin: com.sun.jersey/jersey-servlet

  Class<?> createBeanClass() {
    ClassWriter writer = new ClassWriter(0);
    String name = prefix + Integer.toString(generatedClassCounter.addAndGet(1));
    writer.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, name, null, "java/lang/Object", null);
    MethodVisitor methodVisitor = writer.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
    methodVisitor.visitCode();
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
    methodVisitor.visitInsn(Opcodes.RETURN);
    methodVisitor.visitMaxs(1, 1);
    methodVisitor.visitEnd();
    writer.visitEnd();
    byte[] bytecode = writer.toByteArray();
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    try {
      Class<?> result = (Class<?>) defineClassMethod.invoke(classLoader, name.replace("/", "."), bytecode, 0,
          bytecode.length);
      LOGGER.fine("Created class " + result.getName());
      return result;
    } catch (Throwable t) {
      LOGGER.log(Level.SEVERE, "error calling ClassLoader.defineClass", t);
      return null;
    }
  }
}
origin: com.sun.jersey/jersey-bundle

  Class<?> createBeanClass() {
    ClassWriter writer = new ClassWriter(0);
    String name = prefix + Integer.toString(generatedClassCounter.addAndGet(1));
    writer.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, name, null, "java/lang/Object", null);
    MethodVisitor methodVisitor = writer.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
    methodVisitor.visitCode();
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
    methodVisitor.visitInsn(Opcodes.RETURN);
    methodVisitor.visitMaxs(1, 1);
    methodVisitor.visitEnd();
    writer.visitEnd();
    byte[] bytecode = writer.toByteArray();
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    try {
      Class<?> result = (Class<?>) defineClassMethod.invoke(classLoader, name.replace("/", "."), bytecode, 0,
          bytecode.length);
      LOGGER.fine("Created class " + result.getName());
      return result;
    } catch (Throwable t) {
      LOGGER.log(Level.SEVERE, "error calling ClassLoader.defineClass", t);
      return null;
    }
  }
}
origin: jersey/jersey-1.x

  Class<?> createBeanClass() {
    ClassWriter writer = new ClassWriter(0);
    String name = prefix + Integer.toString(generatedClassCounter.addAndGet(1));
    writer.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, name, null, "java/lang/Object", null);
    MethodVisitor methodVisitor = writer.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
    methodVisitor.visitCode();
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
    methodVisitor.visitInsn(Opcodes.RETURN);
    methodVisitor.visitMaxs(1, 1);
    methodVisitor.visitEnd();
    writer.visitEnd();
    byte[] bytecode = writer.toByteArray();
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    try {
      Class<?> result = (Class<?>) defineClassMethod.invoke(classLoader, name.replace("/", "."), bytecode, 0,
          bytecode.length);
      LOGGER.fine("Created class " + result.getName());
      return result;
    } catch (Throwable t) {
      LOGGER.log(Level.SEVERE, "error calling ClassLoader.defineClass", t);
      return null;
    }
  }
}
jersey.repackaged.org.objectweb.asmClassWritervisitMethod

Popular methods of ClassWriter

  • toByteArray
    Returns the bytecode of the class that was build with this class writer.
  • addType
    Adds the given Item to #typeTable.
  • addUninitializedType
    Adds the given "uninitialized" type to #typeTable and returns its index. This method is used for UNI
  • get
    Returns the constant pool's hash table item which is equal to the given item.
  • getCommonSuperClass
    Returns the common super type of the two given types. The default implementation of this method load
  • getMergedType
    Returns the index of the common super type of the two given types. This method calls #getCommonSuper
  • newClass
    Adds a class reference to the constant pool of the class being build. Does nothing if the constant p
  • newClassItem
    Adds a class reference to the constant pool of the class being build. Does nothing if the constant p
  • newConst
    Adds a number or string constant to the constant pool of the class being build. Does nothing if the
  • newConstItem
    Adds a number or string constant to the constant pool of the class being build. Does nothing if the
  • newDouble
    Adds a double to the constant pool of the class being build. Does nothing if the constant pool alrea
  • newField
    Adds a field reference to the constant pool of the class being build. Does nothing if the constant p
  • newDouble,
  • newField,
  • newFieldItem,
  • newFloat,
  • newHandle,
  • newHandleItem,
  • newInteger,
  • newInvokeDynamicItem,
  • newLong,
  • newMethod

Popular in Java

  • Creating JSON documents from java classes using gson
  • putExtra (Intent)
  • onRequestPermissionsResult (Fragment)
  • getSharedPreferences (Context)
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Best IntelliJ plugins
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