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

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

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

origin: com.sun.jersey/jersey-server

/**
 * Returns the index of the common super type of the two given types. This
 * method calls {@link #getCommonSuperClass} and caches the result in the
 * {@link #items} hash table to speedup future calls with the same
 * parameters.
 *
 * @param type1
 *            index of an internal name in {@link #typeTable}.
 * @param type2
 *            index of an internal name in {@link #typeTable}.
 * @return the index of the common super type of the two given types.
 */
int getMergedType(final int type1, final int type2) {
  key2.type = TYPE_MERGED;
  key2.longVal = type1 | (((long) type2) << 32);
  key2.hashCode = 0x7FFFFFFF & (TYPE_MERGED + type1 + type2);
  Item result = get(key2);
  if (result == null) {
    String t = typeTable[type1].strVal1;
    String u = typeTable[type2].strVal1;
    key2.intVal = addType(getCommonSuperClass(t, u));
    result = new Item((short) 0, key2);
    put(result);
  }
  return result.intVal;
}
origin: com.sun.jersey/jersey-server

        | cw.getMergedType(t & BASE_VALUE, u & BASE_VALUE);
  } else {
    v = vdim | OBJECT | cw.addType("java/lang/Object");
      : ELEMENT_OF) + (u & DIM);
  v = Math.min(tdim, udim) | OBJECT
      | cw.addType("java/lang/Object");
} else {
origin: com.sun.jersey/jersey-server

/**
 * Adds a field reference to the constant pool of the class being build.
 * Does nothing if the constant pool already contains a similar item.
 *
 * @param owner
 *            the internal name of the field's owner class.
 * @param name
 *            the field's name.
 * @param desc
 *            the field's descriptor.
 * @return a new or already existing field reference item.
 */
Item newFieldItem(final String owner, final String name, final String desc) {
  key3.set(FIELD, owner, name, desc);
  Item result = get(key3);
  if (result == null) {
    put122(FIELD, newClass(owner), newNameType(name, desc));
    result = new Item(index++, key3);
    put(result);
  }
  return result;
}
origin: com.sun.jersey/jersey-server

@Override
public final void visitOuterClass(final String owner, final String name,
    final String desc) {
  enclosingMethodOwner = newClass(owner);
  if (name != null && desc != null) {
    enclosingMethod = newNameType(name, desc);
  }
}
origin: com.sun.jersey/jersey-server

@Override
public final void visit(final int version, final int access,
    final String name, final String signature, final String superName,
    final String[] interfaces) {
  this.version = version;
  this.access = access;
  this.name = newClass(name);
  thisName = name;
  if (ClassReader.SIGNATURES && signature != null) {
    this.signature = newUTF8(signature);
  }
  this.superName = superName == null ? 0 : newClass(superName);
  if (interfaces != null && interfaces.length > 0) {
    interfaceCount = interfaces.length;
    this.interfaces = new int[interfaceCount];
    for (int i = 0; i < interfaceCount; ++i) {
      this.interfaces[i] = newClass(interfaces[i]);
    }
  }
}
origin: com.sun.jersey/jersey-server

this.cw = cw;
this.access = access;
this.name = cw.newUTF8(name);
this.desc = cw.newUTF8(desc);
if (ClassReader.SIGNATURES && signature != null) {
  this.signature = cw.newUTF8(signature);
  this.value = cw.newConstItem(value).index;
origin: com.sun.jersey/jersey-server

bootstrapMethods.putShort(newHandle(bsm.tag, bsm.owner, bsm.name,
    bsm.desc));
  Object bsmArg = bsmArgs[i];
  hashCode ^= bsmArg.hashCode();
  bootstrapMethods.putShort(newConst(bsmArg));
  result = new Item(bootstrapMethodIndex);
  result.set(position, hashCode);
  put(result);
result = get(key3);
if (result == null) {
  put122(INDY, bootstrapMethodIndex, newNameType(name, desc));
  result = new Item(index++, key3);
  put(result);
origin: com.sun.jersey/jersey-server

if (cst instanceof Integer) {
  int val = ((Integer) cst).intValue();
  return newInteger(val);
} else if (cst instanceof Byte) {
  int val = ((Byte) cst).intValue();
  return newInteger(val);
} else if (cst instanceof Character) {
  int val = ((Character) cst).charValue();
  return newInteger(val);
} else if (cst instanceof Short) {
  int val = ((Short) cst).intValue();
  return newInteger(val);
} else if (cst instanceof Boolean) {
  int val = ((Boolean) cst).booleanValue() ? 1 : 0;
  return newInteger(val);
} else if (cst instanceof Float) {
  float val = ((Float) cst).floatValue();
  return newFloat(val);
} else if (cst instanceof Long) {
  long val = ((Long) cst).longValue();
  return newLong(val);
} else if (cst instanceof Double) {
  double val = ((Double) cst).doubleValue();
  return newDouble(val);
} else if (cst instanceof String) {
  return newString((String) cst);
} else if (cst instanceof Type) {
  Type t = (Type) cst;
  int s = t.getSort();
origin: com.sun.jersey/jersey-server

++size;
if (named) {
  bv.putShort(cw.newUTF8(name));
  bv.put12('s', cw.newUTF8((String) value));
} else if (value instanceof Byte) {
  bv.put12('B', cw.newInteger(((Byte) value).byteValue()).index);
} else if (value instanceof Boolean) {
  int v = ((Boolean) value).booleanValue() ? 1 : 0;
  bv.put12('Z', cw.newInteger(v).index);
} else if (value instanceof Character) {
  bv.put12('C', cw.newInteger(((Character) value).charValue()).index);
} else if (value instanceof Short) {
  bv.put12('S', cw.newInteger(((Short) value).shortValue()).index);
} else if (value instanceof Type) {
  bv.put12('c', cw.newUTF8(((Type) value).getDescriptor()));
} else if (value instanceof byte[]) {
  byte[] v = (byte[]) value;
  bv.put12('[', v.length);
  for (int i = 0; i < v.length; i++) {
    bv.put12('B', cw.newInteger(v[i]).index);
  bv.put12('[', v.length);
  for (int i = 0; i < v.length; i++) {
    bv.put12('Z', cw.newInteger(v[i] ? 1 : 0).index);
  bv.put12('[', v.length);
  for (int i = 0; i < v.length; i++) {
    bv.put12('S', cw.newInteger(v[i]).index);
origin: com.sun.jersey/jersey-server

if (local[i] instanceof String) {
  frame[frameIndex++] = Frame.OBJECT
      | cw.addType((String) local[i]);
} else if (local[i] instanceof Integer) {
  frame[frameIndex++] = ((Integer) local[i]).intValue();
} else {
  frame[frameIndex++] = Frame.UNINITIALIZED
      | cw.addUninitializedType("",
          ((Label) local[i]).position);
if (stack[i] instanceof String) {
  frame[frameIndex++] = Frame.OBJECT
      | cw.addType((String) stack[i]);
} else if (stack[i] instanceof Integer) {
  frame[frameIndex++] = ((Integer) stack[i]).intValue();
} else {
  frame[frameIndex++] = Frame.UNINITIALIZED
      | cw.addUninitializedType("",
          ((Label) stack[i]).position);
origin: com.sun.jersey/jersey-server

newUTF8("BootstrapMethods");
newUTF8("Signature");
newUTF8("SourceFile");
newUTF8("SourceDebugExtension");
newUTF8("EnclosingMethod");
newUTF8("Deprecated");
  ++attributeCount;
  size += 6;
  newUTF8("Synthetic");
++attributeCount;
size += 8 + innerClasses.length;
newUTF8("InnerClasses");
newUTF8("RuntimeVisibleAnnotations");
newUTF8("RuntimeInvisibleAnnotations");
newUTF8("RuntimeVisibleTypeAnnotations");
newUTF8("RuntimeInvisibleTypeAnnotations");
out.putShort(newUTF8("BootstrapMethods"));
origin: com.sun.jersey/jersey-server

/**
 * Adds a name and type to the constant pool of the class being build. Does
 * nothing if the constant pool already contains a similar item.
 *
 * @param name
 *            a name.
 * @param desc
 *            a type descriptor.
 * @return a new or already existing name and type item.
 */
Item newNameTypeItem(final String name, final String desc) {
  key2.set(NAME_TYPE, name, desc, null);
  Item result = get(key2);
  if (result == null) {
    put122(NAME_TYPE, newUTF8(name), newUTF8(desc));
    result = new Item(index++, key2);
    put(result);
  }
  return result;
}
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-server

/**
 * Adds a string to the constant pool of the class being build. Does nothing
 * if the constant pool already contains a similar item.
 *
 * @param value
 *            the String value.
 * @return a new or already existing string item.
 */
private Item newString(final String value) {
  key2.set(STR, value, null, null);
  Item result = get(key2);
  if (result == null) {
    pool.put12(STR, newUTF8(value));
    result = new Item(index++, key2);
    put(result);
  }
  return result;
}
origin: com.sun.jersey/jersey-server

/**
 * Adds an integer to the constant pool of the class being build. Does
 * nothing if the constant pool already contains a similar item.
 *
 * @param value
 *            the int value.
 * @return a new or already existing int item.
 */
Item newInteger(final int value) {
  key.set(value);
  Item result = get(key);
  if (result == null) {
    pool.putByte(INT).putInt(value);
    result = new Item(index++, key);
    put(result);
  }
  return result;
}
origin: com.sun.jersey/jersey-server

@Override
public final void visitInnerClass(final String name,
    final String outerName, final String innerName, final int access) {
  if (innerClasses == null) {
    innerClasses = new ByteVector();
  }
  // Sec. 4.7.6 of the JVMS states "Every CONSTANT_Class_info entry in the
  // constant_pool table which represents a class or interface C that is
  // not a package member must have exactly one corresponding entry in the
  // classes array". To avoid duplicates we keep track in the intVal field
  // of the Item of each CONSTANT_Class_info entry C whether an inner
  // class entry has already been added for C (this field is unused for
  // class entries, and changing its value does not change the hashcode
  // and equality tests). If so we store the index of this inner class
  // entry (plus one) in intVal. This hack allows duplicate detection in
  // O(1) time.
  Item nameItem = newClassItem(name);
  if (nameItem.intVal == 0) {
    ++innerClassesCount;
    innerClasses.putShort(nameItem.index);
    innerClasses.putShort(outerName == null ? 0 : newClass(outerName));
    innerClasses.putShort(innerName == null ? 0 : newUTF8(innerName));
    innerClasses.putShort(access);
    nameItem.intVal = innerClassesCount;
  } else {
    // Compare the inner classes entry nameItem.intVal - 1 with the
    // arguments of this method and throw an exception if there is a
    // difference?
  }
}
origin: com.sun.jersey/jersey-server

/**
 * Adds the given "uninitialized" type to {@link #typeTable} and returns its
 * index. This method is used for UNINITIALIZED types, made of an internal
 * name and a bytecode offset.
 *
 * @param type
 *            the internal name to be added to the type table.
 * @param offset
 *            the bytecode offset of the NEW instruction that created this
 *            UNINITIALIZED type value.
 * @return the index of this internal name in the type table.
 */
int addUninitializedType(final String type, final int offset) {
  key.type = TYPE_UNINIT;
  key.intVal = offset;
  key.strVal1 = type;
  key.hashCode = 0x7FFFFFFF & (TYPE_UNINIT + type.hashCode() + offset);
  Item result = get(key);
  if (result == null) {
    result = addType(key);
  }
  return result.index;
}
origin: com.sun.jersey/jersey-server

/**
 * Adds a class reference to the constant pool of the class being build.
 * Does nothing if the constant pool already contains a similar item.
 * <i>This method is intended for {@link Attribute} sub classes, and is
 * normally not needed by class generators or adapters.</i>
 *
 * @param value
 *            the internal name of the class.
 * @return the index of a new or already existing class reference item.
 */
public int newClass(final String value) {
  return newClassItem(value).index;
}
origin: com.sun.jersey/jersey-server

/**
 * Adds a number or string constant to the constant pool of the class being
 * build. Does nothing if the constant pool already contains a similar item.
 * <i>This method is intended for {@link Attribute} sub classes, and is
 * normally not needed by class generators or adapters.</i>
 *
 * @param cst
 *            the value of the constant to be added to the constant pool.
 *            This parameter must be an {@link Integer}, a {@link Float}, a
 *            {@link Long}, a {@link Double} or a {@link String}.
 * @return the index of a new or already existing constant item with the
 *         given value.
 */
public int newConst(final Object cst) {
  return newConstItem(cst).index;
}
origin: com.sun.jersey/jersey-server

@Override
public void visitTryCatchBlock(final Label start, final Label end,
    final Label handler, final String type) {
  ++handlerCount;
  Handler h = new Handler();
  h.start = start;
  h.end = end;
  h.handler = handler;
  h.desc = type;
  h.type = type != null ? cw.newClass(type) : 0;
  if (lastHandler == null) {
    firstHandler = h;
  } else {
    lastHandler.next = h;
  }
  lastHandler = h;
}
jersey.repackaged.org.objectweb.asmClassWriter

Javadoc

A ClassVisitor that generates classes in bytecode form. More precisely this visitor generates a byte array conforming to the Java class file format. It can be used alone, to generate a Java class "from scratch", or with one or more ClassReader and adapter class visitor to generate a modified class from one or more existing Java classes.

Most used methods

  • 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

  • Making http post requests using okhttp
  • setRequestProperty (URLConnection)
  • requestLocationUpdates (LocationManager)
  • getSystemService (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • CodeWhisperer alternatives
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