com.sun.org.apache.bcel.internal.generic.Type Java Examples

The following examples show how to use com.sun.org.apache.bcel.internal.generic.Type. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: MethodGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Helper method to generate an instance of a subclass of
 * {@link StoreInstruction} based on the specified {@link Type} that will
 * store a value in the specified local variable
 * @param index the JVM stack frame index of the variable that is to be
 * stored
 * @param type the {@link Type} of the variable
 * @return the generated {@link StoredInstruction}
 */
private static Instruction storeLocal(int index, Type type) {
    if (type == Type.BOOLEAN) {
       return new ISTORE(index);
    } else if (type == Type.INT) {
       return new ISTORE(index);
    } else if (type == Type.SHORT) {
       return new ISTORE(index);
    } else if (type == Type.LONG) {
       return new LSTORE(index);
    } else if (type == Type.BYTE) {
       return new ISTORE(index);
    } else if (type == Type.CHAR) {
       return new ISTORE(index);
    } else if (type == Type.FLOAT) {
       return new FSTORE(index);
    } else if (type == Type.DOUBLE) {
       return new DSTORE(index);
    } else {
       return new ASTORE(index);
    }
}
 
Example #2
Source Project: openjdk-8   Author: bpupadhyaya   File: MethodGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Helper method to generate an instance of a subclass of
 * {@link StoreInstruction} based on the specified {@link Type} that will
 * store a value in the specified local variable
 * @param index the JVM stack frame index of the variable that is to be
 * stored
 * @param type the {@link Type} of the variable
 * @return the generated {@link StoredInstruction}
 */
private static Instruction storeLocal(int index, Type type) {
    if (type == Type.BOOLEAN) {
       return new ISTORE(index);
    } else if (type == Type.INT) {
       return new ISTORE(index);
    } else if (type == Type.SHORT) {
       return new ISTORE(index);
    } else if (type == Type.LONG) {
       return new LSTORE(index);
    } else if (type == Type.BYTE) {
       return new ISTORE(index);
    } else if (type == Type.CHAR) {
       return new ISTORE(index);
    } else if (type == Type.FLOAT) {
       return new FSTORE(index);
    } else if (type == Type.DOUBLE) {
       return new DSTORE(index);
    } else {
       return new ASTORE(index);
    }
}
 
Example #3
Source Project: hottub   Author: dsrg-uoft   File: MethodGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Helper method to generate an instance of a subclass of
 * {@link LoadInstruction} based on the specified {@link Type} that will
 * load the specified local variable
 * @param index the JVM stack frame index of the variable that is to be
 * loaded
 * @param type the {@link Type} of the variable
 * @return the generated {@link LoadInstruction}
 */
private static Instruction loadLocal(int index, Type type) {
    if (type == Type.BOOLEAN) {
       return new ILOAD(index);
    } else if (type == Type.INT) {
       return new ILOAD(index);
    } else if (type == Type.SHORT) {
       return new ILOAD(index);
    } else if (type == Type.LONG) {
       return new LLOAD(index);
    } else if (type == Type.BYTE) {
       return new ILOAD(index);
    } else if (type == Type.CHAR) {
       return new ILOAD(index);
    } else if (type == Type.FLOAT) {
       return new FLOAD(index);
    } else if (type == Type.DOUBLE) {
       return new DLOAD(index);
    } else {
       return new ALOAD(index);
    }
}
 
Example #4
Source Project: jdk8u60   Author: chenghanpeng   File: MethodGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Helper method to generate an instance of a subclass of
 * {@link StoreInstruction} based on the specified {@link Type} that will
 * store a value in the specified local variable
 * @param index the JVM stack frame index of the variable that is to be
 * stored
 * @param type the {@link Type} of the variable
 * @return the generated {@link StoredInstruction}
 */
private static Instruction storeLocal(int index, Type type) {
    if (type == Type.BOOLEAN) {
       return new ISTORE(index);
    } else if (type == Type.INT) {
       return new ISTORE(index);
    } else if (type == Type.SHORT) {
       return new ISTORE(index);
    } else if (type == Type.LONG) {
       return new LSTORE(index);
    } else if (type == Type.BYTE) {
       return new ISTORE(index);
    } else if (type == Type.CHAR) {
       return new ISTORE(index);
    } else if (type == Type.FLOAT) {
       return new FSTORE(index);
    } else if (type == Type.DOUBLE) {
       return new DSTORE(index);
    } else {
       return new ASTORE(index);
    }
}
 
Example #5
Source Project: hottub   Author: dsrg-uoft   File: CompareGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CompareGenerator(int access_flags, Type return_type,
                        Type[] arg_types, String[] arg_names,
                        String method_name, String class_name,
                        InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _iloadCurrent = new ILOAD(CURRENT_INDEX);
    _istoreCurrent = new ISTORE(CURRENT_INDEX);
    _aloadDom = new ALOAD(DOM_INDEX);
    _iloadLast = new ILOAD(LAST_INDEX);

    LocalVariableGen iterator =
        addLocalVariable("iterator",
                         Util.getJCRefType(Constants.NODE_ITERATOR_SIG),
                         null, null);
    ITERATOR_INDEX = iterator.getIndex();
    _aloadIterator = new ALOAD(ITERATOR_INDEX);
    _astoreIterator = new ASTORE(ITERATOR_INDEX);
    il.append(new ACONST_NULL());
    il.append(storeIterator());
}
 
Example #6
Source Project: jdk8u60   Author: chenghanpeng   File: CompareGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
public CompareGenerator(int access_flags, Type return_type,
                        Type[] arg_types, String[] arg_names,
                        String method_name, String class_name,
                        InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _iloadCurrent = new ILOAD(CURRENT_INDEX);
    _istoreCurrent = new ISTORE(CURRENT_INDEX);
    _aloadDom = new ALOAD(DOM_INDEX);
    _iloadLast = new ILOAD(LAST_INDEX);

    LocalVariableGen iterator =
        addLocalVariable("iterator",
                         Util.getJCRefType(Constants.NODE_ITERATOR_SIG),
                         null, null);
    ITERATOR_INDEX = iterator.getIndex();
    _aloadIterator = new ALOAD(ITERATOR_INDEX);
    _astoreIterator = new ASTORE(ITERATOR_INDEX);
    il.append(new ACONST_NULL());
    il.append(storeIterator());
}
 
Example #7
Source Project: openjdk-8   Author: bpupadhyaya   File: MethodGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Helper method to generate an instance of a subclass of
 * {@link LoadInstruction} based on the specified {@link Type} that will
 * load the specified local variable
 * @param index the JVM stack frame index of the variable that is to be
 * loaded
 * @param type the {@link Type} of the variable
 * @return the generated {@link LoadInstruction}
 */
private static Instruction loadLocal(int index, Type type) {
    if (type == Type.BOOLEAN) {
       return new ILOAD(index);
    } else if (type == Type.INT) {
       return new ILOAD(index);
    } else if (type == Type.SHORT) {
       return new ILOAD(index);
    } else if (type == Type.LONG) {
       return new LLOAD(index);
    } else if (type == Type.BYTE) {
       return new ILOAD(index);
    } else if (type == Type.CHAR) {
       return new ILOAD(index);
    } else if (type == Type.FLOAT) {
       return new FLOAD(index);
    } else if (type == Type.DOUBLE) {
       return new DLOAD(index);
    } else {
       return new ALOAD(index);
    }
}
 
Example #8
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: MethodGenerator.java    License: MIT License 6 votes vote down vote up
/**
 * Helper method to generate an instance of a subclass of
 * {@link StoreInstruction} based on the specified {@link Type} that will
 * store a value in the specified local variable
 * @param index the JVM stack frame index of the variable that is to be
 * stored
 * @param type the {@link Type} of the variable
 * @return the generated {@link StoredInstruction}
 */
private static Instruction storeLocal(int index, Type type) {
    if (type == Type.BOOLEAN) {
       return new ISTORE(index);
    } else if (type == Type.INT) {
       return new ISTORE(index);
    } else if (type == Type.SHORT) {
       return new ISTORE(index);
    } else if (type == Type.LONG) {
       return new LSTORE(index);
    } else if (type == Type.BYTE) {
       return new ISTORE(index);
    } else if (type == Type.CHAR) {
       return new ISTORE(index);
    } else if (type == Type.FLOAT) {
       return new FSTORE(index);
    } else if (type == Type.DOUBLE) {
       return new DSTORE(index);
    } else {
       return new ASTORE(index);
    }
}
 
Example #9
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: MethodGenerator.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Helper method to generate an instance of a subclass of
 * {@link LoadInstruction} based on the specified {@link Type} that will
 * load the specified local variable
 * @param index the JVM stack frame index of the variable that is to be
 * loaded
 * @param type the {@link Type} of the variable
 * @return the generated {@link LoadInstruction}
 */
private static Instruction loadLocal(int index, Type type) {
    if (type == Type.BOOLEAN) {
       return new ILOAD(index);
    } else if (type == Type.INT) {
       return new ILOAD(index);
    } else if (type == Type.SHORT) {
       return new ILOAD(index);
    } else if (type == Type.LONG) {
       return new LLOAD(index);
    } else if (type == Type.BYTE) {
       return new ILOAD(index);
    } else if (type == Type.CHAR) {
       return new ILOAD(index);
    } else if (type == Type.FLOAT) {
       return new FLOAD(index);
    } else if (type == Type.DOUBLE) {
       return new DLOAD(index);
    } else {
       return new ALOAD(index);
    }
}
 
Example #10
Source Project: Bytecoder   Author: mirkosertic   File: MethodGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Helper method to generate an instance of a subclass of
 * {@link StoreInstruction} based on the specified {@link Type} that will
 * store a value in the specified local variable
 * @param index the JVM stack frame index of the variable that is to be
 * stored
 * @param type the {@link Type} of the variable
 * @return the generated {@link StoredInstruction}
 */
private static Instruction storeLocal(int index, Type type) {
    if (type == Type.BOOLEAN) {
       return new ISTORE(index);
    } else if (type == Type.INT) {
       return new ISTORE(index);
    } else if (type == Type.SHORT) {
       return new ISTORE(index);
    } else if (type == Type.LONG) {
       return new LSTORE(index);
    } else if (type == Type.BYTE) {
       return new ISTORE(index);
    } else if (type == Type.CHAR) {
       return new ISTORE(index);
    } else if (type == Type.FLOAT) {
       return new FSTORE(index);
    } else if (type == Type.DOUBLE) {
       return new DSTORE(index);
    } else {
       return new ASTORE(index);
    }
}
 
Example #11
Source Project: Bytecoder   Author: mirkosertic   File: MethodGenerator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Helper method to generate an instance of a subclass of
 * {@link LoadInstruction} based on the specified {@link Type} that will
 * load the specified local variable
 * @param index the JVM stack frame index of the variable that is to be
 * loaded
 * @param type the {@link Type} of the variable
 * @return the generated {@link LoadInstruction}
 */
private static Instruction loadLocal(int index, Type type) {
    if (type == Type.BOOLEAN) {
       return new ILOAD(index);
    } else if (type == Type.INT) {
       return new ILOAD(index);
    } else if (type == Type.SHORT) {
       return new ILOAD(index);
    } else if (type == Type.LONG) {
       return new LLOAD(index);
    } else if (type == Type.BYTE) {
       return new ILOAD(index);
    } else if (type == Type.CHAR) {
       return new ILOAD(index);
    } else if (type == Type.FLOAT) {
       return new FLOAD(index);
    } else if (type == Type.DOUBLE) {
       return new DLOAD(index);
    } else {
       return new ALOAD(index);
    }
}
 
Example #12
Source Project: Bytecoder   Author: mirkosertic   File: BCELFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void visitFieldInstruction( final FieldInstruction i ) {
    final short opcode = i.getOpcode();
    final String class_name = i.getReferenceType(_cp).getSignature();
    final String field_name = i.getFieldName(_cp);
    final Type type = i.getFieldType(_cp);
    _out.println("il.append(_factory.createFieldAccess(\"" + class_name + "\", \"" + field_name
            + "\", " + BCELifier.printType(type) + ", " + CONSTANT_PREFIX
            + Const.getOpcodeName(opcode).toUpperCase(Locale.ENGLISH) + "));");
}
 
Example #13
Source Project: hottub   Author: dsrg-uoft   File: MethodGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
public LocalVariableGen addLocalVariable2(String name, Type type,
                                          InstructionHandle start)
{
    LocalVariableGen lvg = super.addLocalVariable(name, type,
                                          _slotAllocator.allocateSlot(type),
                                          start, null);
    getLocalVariableRegistry().registerLocalVariable(lvg);
    return lvg;
}
 
Example #14
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: MethodGenerator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Allocates a local variable. If the slot allocator has already been
 * initialized, then call addLocalVariable2() so that the new variable
 * is known to the allocator. Failing to do this may cause the allocator
 * to return a slot that is already in use.
 */
public LocalVariableGen addLocalVariable(String name, Type type,
                                         InstructionHandle start,
                                         InstructionHandle end)
{
    LocalVariableGen lvg;

    if (_allocatorInit) {
        lvg = addLocalVariable2(name, type, start);
    } else {
        lvg = super.addLocalVariable(name, type, start, end);
        getLocalVariableRegistry().registerLocalVariable(lvg);
    }
    return lvg;
}
 
Example #15
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: MethodGenerator.java    License: Apache License 2.0 5 votes vote down vote up
public LocalVariableGen addLocalVariable2(String name, Type type,
                                          InstructionHandle start)
{
    LocalVariableGen lvg = super.addLocalVariable(name, type,
                                          _slotAllocator.allocateSlot(type),
                                          start, null);
    getLocalVariableRegistry().registerLocalVariable(lvg);
    return lvg;
}
 
Example #16
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: RtMethodGenerator.java    License: Apache License 2.0 5 votes vote down vote up
public RtMethodGenerator(int access_flags, Type return_type,
                         Type[] arg_types, String[] arg_names,
                         String method_name, String class_name,
                         InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _astoreHandler = new ASTORE(HANDLER_INDEX);
    _aloadHandler  = new ALOAD(HANDLER_INDEX);
}
 
Example #17
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: MatchGenerator.java    License: Apache License 2.0 5 votes vote down vote up
public MatchGenerator(int access_flags, Type return_type,
                      Type[] arg_types, String[] arg_names,
                      String method_name, String class_name,
                      InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _iloadCurrent = new ILOAD(CURRENT_INDEX);
    _istoreCurrent = new ISTORE(CURRENT_INDEX);
}
 
Example #18
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: NamedMethodGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
public NamedMethodGenerator(int access_flags, Type return_type,
                            Type[] arg_types, String[] arg_names,
                            String method_name, String class_name,
                            InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);
}
 
Example #19
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: JavaClass.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return A com.sun.org.apache.bcel.internal.classfile.Method corresponding to
 * java.lang.reflect.Method if any
 */
public Method getMethod(java.lang.reflect.Method m) {
  for(int i = 0; i < methods.length; i++) {
    Method method = methods[i];

    if(m.getName().equals(method.getName()) &&
       (m.getModifiers() == method.getModifiers()) &&
       Type.getSignature(m).equals(method.getSignature())) {
      return method;
    }
  }

  return null;
}
 
Example #20
Source Project: Bytecoder   Author: mirkosertic   File: AttributeSetMethodGenerator.java    License: Apache License 2.0 5 votes vote down vote up
public AttributeSetMethodGenerator(String methodName, ClassGenerator classGen) {
     super(com.sun.org.apache.bcel.internal.Const.ACC_PRIVATE,
           com.sun.org.apache.bcel.internal.generic.Type.VOID,
           argTypes, argNames, methodName,
           classGen.getClassName(),
           new InstructionList(),
           classGen.getConstantPool());
}
 
Example #21
Source Project: openjdk-8-source   Author: keerath   File: RtMethodGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
public RtMethodGenerator(int access_flags, Type return_type,
                         Type[] arg_types, String[] arg_names,
                         String method_name, String class_name,
                         InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _astoreHandler = new ASTORE(HANDLER_INDEX);
    _aloadHandler  = new ALOAD(HANDLER_INDEX);
}
 
Example #22
Source Project: cacheonix-core   Author: cacheonix   File: CacheonixMethodVisitor.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Adds all method parameters to the parameterAnnotatonIndices
 */
private void updateParameterIndicesForCacheDataSource() {

   parameterAnnotatonIndices.clear();
   final Type[] argTypeArray = Type.getArgumentTypes(desc);
   for (int i = 0; i < argTypeArray.length; ++i) {
      parameterAnnotatonIndices.add(Integer.valueOf(i));
   }
}
 
Example #23
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: TestGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestGenerator(int access_flags, Type return_type,
                     Type[] arg_types, String[] arg_names,
                     String method_name, String class_name,
                     InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _iloadCurrent  = new ILOAD(CURRENT_NODE_INDEX);
    _istoreCurrent = new ISTORE(CURRENT_NODE_INDEX);
    _iloadContext  = new ILOAD(CONTEXT_NODE_INDEX);
    _istoreContext  = new ILOAD(CONTEXT_NODE_INDEX);
    _astoreIterator = new ASTORE(ITERATOR_INDEX);
    _aloadIterator  = new ALOAD(ITERATOR_INDEX);
}
 
Example #24
Source Project: openjdk-8   Author: bpupadhyaya   File: NamedMethodGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
public NamedMethodGenerator(int access_flags, Type return_type,
                            Type[] arg_types, String[] arg_names,
                            String method_name, String class_name,
                            InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);
}
 
Example #25
Source Project: TencentKona-8   Author: Tencent   File: SlotAllocator.java    License: GNU General Public License v2.0 5 votes vote down vote up
public int allocateSlot(Type type) {
    final int size = type.getSize();
    final int limit = _free;
    int slot = _firstAvailableSlot, where = 0;

    if (_free + size > _size) {
        final int[] array = new int[_size *= 2];
        for (int j = 0; j < limit; j++)
            array[j] = _slotsTaken[j];
        _slotsTaken = array;
    }

    while (where < limit) {
        if (slot + size <= _slotsTaken[where]) {
            // insert
            for (int j = limit - 1; j >= where; j--)
                _slotsTaken[j + size] = _slotsTaken[j];
            break;
        }
        else {
            slot = _slotsTaken[where++] + 1;
        }
    }

    for (int j = 0; j < size; j++)
        _slotsTaken[where + j] = slot + j;

    _free += size;
    return slot;
}
 
Example #26
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: AttributeSetMethodGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
public AttributeSetMethodGenerator(String methodName, ClassGenerator classGen) {
     super(com.sun.org.apache.bcel.internal.Constants.ACC_PRIVATE,
           com.sun.org.apache.bcel.internal.generic.Type.VOID,
           argTypes, argNames, methodName,
           classGen.getClassName(),
           new InstructionList(),
           classGen.getConstantPool());
}
 
Example #27
Source Project: TencentKona-8   Author: Tencent   File: MatchGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
public MatchGenerator(int access_flags, Type return_type,
                      Type[] arg_types, String[] arg_names,
                      String method_name, String class_name,
                      InstructionList il, ConstantPoolGen cp) {
    super(access_flags, return_type, arg_types, arg_names, method_name,
          class_name, il, cp);

    _iloadCurrent = new ILOAD(CURRENT_INDEX);
    _istoreCurrent = new ISTORE(CURRENT_INDEX);
}
 
Example #28
Source Project: Bytecoder   Author: mirkosertic   File: BCELifier.java    License: Apache License 2.0 5 votes vote down vote up
static String printArgumentTypes( final Type[] arg_types ) {
    if (arg_types.length == 0) {
        return "Type.NO_ARGS";
    }
    final StringBuilder args = new StringBuilder();
    for (int i = 0; i < arg_types.length; i++) {
        args.append(printType(arg_types[i]));
        if (i < arg_types.length - 1) {
            args.append(", ");
        }
    }
    return "new Type[] { " + args.toString() + " }";
}
 
Example #29
Source Project: Bytecoder   Author: mirkosertic   File: BCELFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void visitLocalVariableInstruction( final LocalVariableInstruction i ) {
    final short opcode = i.getOpcode();
    final Type type = i.getType(_cp);
    if (opcode == Const.IINC) {
        _out.println("il.append(new IINC(" + i.getIndex() + ", " + ((IINC) i).getIncrement()
                + "));");
    } else {
        final String kind = (opcode < Const.ISTORE) ? "Load" : "Store";
        _out.println("il.append(_factory.create" + kind + "(" + BCELifier.printType(type)
                + ", " + i.getIndex() + "));");
    }
}
 
Example #30
Source Project: jdk8u60   Author: chenghanpeng   File: AttributeSetMethodGenerator.java    License: GNU General Public License v2.0 5 votes vote down vote up
public AttributeSetMethodGenerator(String methodName, ClassGenerator classGen) {
     super(com.sun.org.apache.bcel.internal.Constants.ACC_PRIVATE,
           com.sun.org.apache.bcel.internal.generic.Type.VOID,
           argTypes, argNames, methodName,
           classGen.getClassName(),
           new InstructionList(),
           classGen.getConstantPool());
}