org.apache.bcel.generic.NEW类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(215)

本文整理了Java中org.apache.bcel.generic.NEW类的一些代码示例,展示了NEW类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NEW类的具体详情如下:
包路径:org.apache.bcel.generic.NEW
类名称:NEW

NEW介绍

[英]NEW - Create new object

Stack: ... -> ..., objectref

[中]新建-创建新对象

Stack: ... -> ..., objectref

代码示例

代码示例来源:origin: xalan/xalan

/**
 * Expects an integer on the stack and pushes a boxed integer.
 * Boxed integers are represented by an instance of
 * <code>java.lang.Integer</code>.
 *
 * @see    org.apache.xalan.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 
      ReferenceType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
il.append(new NEW(cpg.addClass(INTEGER_CLASS)));
il.append(DUP_X1);
il.append(SWAP);
il.append(new INVOKESPECIAL(cpg.addMethodref(INTEGER_CLASS,
             "<init>", "(I)V")));
}

代码示例来源:origin: spotbugs/spotbugs

public static boolean isNullCheck(InstructionHandle h, ConstantPoolGen cpg) {
  if (!(h.getInstruction() instanceof IFNONNULL)) {
    return false;
  }
  h = h.getNext();
  final Instruction newInstruction = h.getInstruction();
  if (!(newInstruction instanceof NEW)) {
    return false;
  }
  final ObjectType loadClassType = ((NEW) newInstruction).getLoadClassType(cpg);
  if (!"java.lang.NullPointerException".equals(loadClassType.getClassName())) {
    return false;
  }
  h = h.getNext();
  return check(h, NULLCHECK1) || check(h, NULLCHECK2);
}

代码示例来源:origin: spotbugs/spotbugs

@Override
public void visitNEW(NEW obj) {
  // FIXME: type is technically "uninitialized"
  // However, we don't model that yet.
  pushValue(obj.getType(getCPG()));
  // We now have an exact type for this value.
  setTopOfStackIsExact();
}

代码示例来源:origin: bcel/bcel

/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
public void visitNEW(NEW o){
  indexValid(o, o.getIndex());
  Constant c = cpg.getConstant(o.getIndex());
  if (!	(c instanceof ConstantClass)){
    constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
  }
  else{
    ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant( ((ConstantClass) c).getNameIndex() ));
    Type t = Type.getType("L"+cutf8.getBytes()+";");
    if (t instanceof ArrayType){
      constraintViolated(o, "NEW must not be used to create an array.");
    }
  }
  
}

代码示例来源:origin: org.apache.bcel/bcel

/** Checks if the constraints of operands of the said instruction(s) are satisfied. */
@Override
public void visitNEW(final NEW o) {
  indexValid(o, o.getIndex());
  final Constant c = cpg.getConstant(o.getIndex());
  if (!    (c instanceof ConstantClass)) {
    constraintViolated(o, "Expecting a CONSTANT_Class operand, but found a '"+c+"'.");
  }
  else{
    final ConstantUtf8 cutf8 = (ConstantUtf8) (cpg.getConstant( ((ConstantClass) c).getNameIndex() ));
    final Type t = Type.getType("L"+cutf8.getBytes()+";");
    if (t instanceof ArrayType) {
      constraintViolated(o, "NEW must not be used to create an array.");
    }
  }
}

代码示例来源:origin: xalan/xalan

/**
 * Expects a boolean on the stack and pushes a boxed boolean.
 * Boxed booleans are represented by an instance of
 * <code>java.lang.Boolean</code>.
 *
 * @see    org.apache.xalan.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 
      ReferenceType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
il.append(new NEW(cpg.addClass(BOOLEAN_CLASS)));
il.append(DUP_X1);
il.append(SWAP);
il.append(new INVOKESPECIAL(cpg.addMethodref(BOOLEAN_CLASS,
             "<init>",
             "(Z)V")));
}

代码示例来源:origin: org.apache.bcel/bcel

@Override
public ObjectType getLoadClassType( final ConstantPoolGen cpg ) {
  return (ObjectType) getType(cpg);
}

代码示例来源:origin: find-sec-bugs/find-sec-bugs

} else if (ins instanceof NEW) {
  NEW i = (NEW) ins;
  ObjectType type = i.getLoadClassType(cpg);
  System.out.println(formatName(ins) + " " + type.toString());
} else if (ins instanceof LoadInstruction) {

代码示例来源:origin: xalan/xalan

/**
 * Expects a node on the stack and pushes a singleton node-set. Singleton
 * iterators are already started after construction.
 *
 * @see    org.apache.xalan.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 
      NodeSetType type) {
ConstantPoolGen cpg = classGen.getConstantPool();
InstructionList il = methodGen.getInstructionList();
// Create a new instance of SingletonIterator
il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR)));
il.append(DUP_X1);
il.append(SWAP);
final int init = cpg.addMethodref(SINGLETON_ITERATOR, "<init>",
         "(" + NODE_SIG +")V");
il.append(new INVOKESPECIAL(init));
}

代码示例来源:origin: bcel/bcel

public ObjectType getLoadClassType(ConstantPoolGen cpg) {
 return (ObjectType)getType(cpg);
}

代码示例来源:origin: com.google.code.findbugs/findbugs

public static boolean isNullCheck(InstructionHandle h, ConstantPoolGen cpg) {
  if (!(h.getInstruction() instanceof IFNONNULL)) {
    return false;
  }
  h = h.getNext();
  final Instruction newInstruction = h.getInstruction();
  if (!(newInstruction instanceof NEW)) {
    return false;
  }
  final ObjectType loadClassType = ((NEW) newInstruction).getLoadClassType(cpg);
  if (!"java.lang.NullPointerException".equals(loadClassType.getClassName())) {
    return false;
  }
  h = h.getNext();
  return check(h, NULLCHECK1) || check(h, NULLCHECK2);
}

代码示例来源:origin: xalan/xalan

/**
 * Expects a double on the stack and pushes a boxed double. Boxed 
 * double are represented by an instance of <code>java.lang.Double</code>.
 *
 * @see    org.apache.xalan.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 
      ReferenceType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
il.append(new NEW(cpg.addClass(DOUBLE_CLASS)));
il.append(DUP_X2);
il.append(DUP_X2);
il.append(POP);
il.append(new INVOKESPECIAL(cpg.addMethodref(DOUBLE_CLASS,
             "<init>", "(D)V")));
}

代码示例来源:origin: com.google.code.findbugs/findbugs

@Override
public void visitNEW(NEW obj) {
  // FIXME: type is technically "uninitialized"
  // However, we don't model that yet.
  pushValue(obj.getType(getCPG()));
  // We now have an exact type for this value.
  setTopOfStackIsExact();
}

代码示例来源:origin: com.h3xstream.findsecbugs/findsecbugs-plugin

} else if (ins instanceof NEW) {
  NEW i = (NEW) ins;
  ObjectType type = i.getLoadClassType(cpg);
  System.out.println(formatName(ins) + " " + type.toString());
} else if (ins instanceof LoadInstruction) {

代码示例来源:origin: xalan/xalan

/**
 * Expects a node on the stack and pushes a boxed node. Boxed nodes
 * are represented by an instance of <code>org.apache.xalan.xsltc.dom.Node</code>.
 *
 * @see    org.apache.xalan.xsltc.compiler.util.Type#translateTo
 */
public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 
      ReferenceType type) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
il.append(new NEW(cpg.addClass(RUNTIME_NODE_CLASS)));
il.append(DUP_X1);
il.append(SWAP);
il.append(new PUSH(cpg, _type));
il.append(new INVOKESPECIAL(cpg.addMethodref(RUNTIME_NODE_CLASS,
             "<init>", "(II)V")));
}

代码示例来源:origin: org.apache.bcel/bcel

/** Symbolically executes the corresponding Java Virtual Machine instruction. */
@Override
public void visitNEW(final NEW o) {
  stack().push(new UninitializedObjectType((ObjectType) (o.getType(cpg))));
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */

代码示例来源:origin: com.h3xstream.findsecbugs/findsecbugs-plugin

@Override
public void visitNEW(NEW obj) {
  Taint taint = new Taint(Taint.State.SAFE);
  ObjectType type = obj.getLoadClassType(cpg);
  taint.setRealInstanceClass(type);
  if (FindSecBugsGlobalConfig.getInstance().isDebugTaintState()) {
    taint.setDebugInfo("new " + type.getClassName() + "()");
  }
  getFrame().pushValue(taint);
}

代码示例来源:origin: xalan/xalan

il.append(new NEW(cpg.addClass(_className)));
il.append(InstructionConstants.DUP);

代码示例来源:origin: bcel/bcel

/** Symbolically executes the corresponding Java Virtual Machine instruction. */ 
public void visitNEW(NEW o){
  stack().push(new UninitializedObjectType((ObjectType) (o.getType(cpg))));
}
/** Symbolically executes the corresponding Java Virtual Machine instruction. */

代码示例来源:origin: blackarbiter/Android_Code_Arbiter

@Override
public void visitNEW(NEW obj) {
  Taint taint = new Taint(Taint.State.SAFE);
  ObjectType type = obj.getLoadClassType(cpg);
  taint.setRealInstanceClass(type);
  if (FindSecBugsGlobalConfig.getInstance().isDebugTaintState()) {
    taint.setDebugInfo("new " + type.getClassName() + "()");
  }
  getFrame().pushValue(taint);
}

相关文章

微信公众号

最新文章

更多