本文整理汇总了Java中org.apache.bcel.generic.Type.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java Type.STRING属性的具体用法?Java Type.STRING怎么用?Java Type.STRING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.bcel.generic.Type
的用法示例。
在下文中一共展示了Type.STRING属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHelperMethodForDotClassCalls
/**
* Creates a method class$(String) which is used
* during SomeClass.class instruction
*
* @param generatedClassName the instance class name
*/
protected void createHelperMethodForDotClassCalls(String generatedClassName) {
InstructionList il = new InstructionList();
MethodGen method = new MethodGen(Constants.ACC_STATIC, new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, new String[]{"arg0"}, "class$", generatedClassName, il, constantsPool);
InstructionHandle ih0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0));
il.append(factory.createInvoke("java.lang.Class", "forName", new ObjectType("java.lang.Class"), new Type[]{Type.STRING}, Constants.INVOKESTATIC));
InstructionHandle ih4 = il.append(InstructionFactory.createReturn(Type.OBJECT));
InstructionHandle ih5 = il.append(InstructionFactory.createStore(Type.OBJECT, 1));
il.append(factory.createNew("java.lang.NoClassDefFoundError"));
il.append(InstructionConstants.DUP);
il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
il.append(factory.createInvoke("java.lang.Throwable", "getMessage", Type.STRING, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(factory.createInvoke("java.lang.NoClassDefFoundError", "<init>", Type.VOID, new Type[]{Type.STRING}, Constants.INVOKESPECIAL));
il.append(InstructionConstants.ATHROW);
method.addExceptionHandler(ih0, ih4, ih5, new ObjectType("java.lang.ClassNotFoundException"));
method.setMaxStack();
method.setMaxLocals();
classGen.addMethod(method.getMethod());
il.dispose();
}
示例2: createInstructionPush
private CompoundInstruction createInstructionPush(Element inst) throws IllegalXMLVMException {
String t = inst.getAttributeValue("type");
Type type = parseTypeString(t);
String value = inst.getAttributeValue("value");
if (type == Type.STRING)
return new PUSH(constantPoolGen, value);
else if (type == Type.INT)
return new PUSH(constantPoolGen, Integer.parseInt(value));
else if (type == Type.FLOAT)
return new PUSH(constantPoolGen, Float.parseFloat(value));
else if (type == Type.DOUBLE)
return new PUSH(constantPoolGen, Double.parseDouble(value));
else if (type == Type.LONG)
return new PUSH(constantPoolGen, Long.parseLong(value));
else
throw new IllegalXMLVMException(inst.getName() + " with bad type '" + t + "'");
}
示例3: mergeReferenceTypes
@Override
protected ReferenceType mergeReferenceTypes(ReferenceType aRef, ReferenceType bRef) throws DataflowAnalysisException {
byte aType = aRef.getType();
byte bType = bRef.getType();
if (isExtendedStringType(aType) || isExtendedStringType(bType)) {
// If both types are the same extended String type,
// then the same type is returned. Otherwise, extended
// types are downgraded to plain java.lang.String,
// and a standard merge is applied.
if (aType == bType) {
return aRef;
}
if (isExtendedStringType(aType)) {
aRef = Type.STRING;
}
if (isExtendedStringType(bType)) {
bRef = Type.STRING;
}
}
return super.mergeReferenceTypes(aRef, bRef);
}
示例4: getJavaTypeForMethod
/**
* The type that will be used when this class is stored as a member, or as a return
* type from a method.
*/
protected Type getJavaTypeForMethod()
{
return Type.STRING;
}
示例5: getJavaType
public Type getJavaType()
{
return Type.STRING;
}
示例6: generateMain
void generateMain(ClassGen clg, Method origMain) {
InstructionList il = new InstructionList();
MethodGen new_main = new MethodGen(Constants.ACC_STATIC
| Constants.ACC_PUBLIC, Type.VOID, new Type[] { new ArrayType(
Type.STRING, 1) }, new String[] { "argv" }, "main", clg
.getClassName(), il, clg.getConstantPool());
il.append(ins_f.createNew(cashmereType));
il.append(new DUP());
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "<init>",
Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "isMaster",
Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
BranchHandle ifcmp = il.append(new IFEQ(null));
InstructionHandle origMain_handle = il.append(new ALOAD(0));
InstructionHandle try_start = il.append(ins_f.createInvoke(clg
.getClassName(), origMain.getName(), Type.VOID,
new Type[] { new ArrayType(Type.STRING, 1) },
Constants.INVOKESTATIC));
BranchHandle try_end = il.append(new GOTO(null));
InstructionHandle e_handler = il.append(getCashmere(ins_f));
il.append(new SWAP());
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "exit",
Type.VOID, new Type[] { new ObjectType("java.lang.Throwable")},
Constants.INVOKEVIRTUAL));
BranchHandle gto2 = il.append(new GOTO(null));
InstructionHandle ifeq_target = il.append(getCashmere(ins_f));
ifcmp.setTarget(ifeq_target);
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "client",
Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(getCashmere(ins_f));
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "isMaster",
Type.BOOLEAN, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(new IFNE(origMain_handle));
InstructionHandle gto_target = il.append(getCashmere(ins_f));
try_end.setTarget(gto_target);
il.append(ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "exit",
Type.VOID, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
InstructionHandle gto2_target = il.append(new RETURN());
gto2.setTarget(gto2_target);
new_main.addExceptionHandler(try_start, try_end, e_handler,
new ObjectType("java.lang.Throwable"));
new_main.setMaxStack();
new_main.setMaxLocals();
new_main.addLocalVariable("argv", new ArrayType(Type.STRING, 1), 0,
origMain_handle, null);
removeLocalTypeTables(new_main);
Method main = new_main.getMethod();
gen_c.addMethod(main);
}
示例7: processParameter
protected void processParameter(ParsedMethod m, Argument arg,
InstructionList il, String queryClass) {
Param param = null;
Position pos = null;
String tempType = null;
for (Annotation a : arg.getAnnotations()) {
if (a instanceof Temporal) {
Temporal t = ((Temporal) a);
tempType = t.value().name();
continue;
} else if (a instanceof Param) {
param = (Param) a;
break;
} else if (a instanceof Position) {
pos = (Position) a;
break;
} else if (a instanceof MaxResults) {
processQuerySetOperation(m, arg, il, "setMaxResults",
queryClass);
return;
} else if (a instanceof FirstResult) {
processQuerySetOperation(m, arg, il, "setFirstResult",
queryClass);
return;
}
}
if ((param == null) == (pos == null)) {
throw new IllegalArgumentException("Unbound parameter #"
+ arg.getArgNo() + " in " + m);
}
int maxRep = 1;
if (pos != null) {
maxRep = pos.value().length;
}
for (int j = 0; j < maxRep; j++) {
Type parmType;
if (pos != null) {
il.append(new PUSH(_cp, pos.value()[j]));
parmType = Type.INT;
} else {
il.append(new PUSH(_cp, param.value()));
parmType = Type.STRING;
}
Class<?> type = arg.getArgumentClass();
if (type == Calendar.class || type == Date.class) {
if (tempType == null)
tempType = TemporalType.TIMESTAMP.name();
}
if (tempType != null
&& (type != Calendar.class && type != Date.class))
throw new IllegalArgumentException(
"Temporal annotation on non-Date, non-Calendar parameter on "
+ m);
arg.pushAsObject(il);
if (tempType == null) {
il.append(_factory.createInvoke(queryClass, "setParameter",
new ObjectType(queryClass), new Type[] { parmType,
Type.OBJECT }, Constants.INVOKEINTERFACE));
} else {
il.append(_factory.createFieldAccess(
"javax.persistence.TemporalType", tempType, TEMPORAL_TYPE,
Constants.GETSTATIC));
il.append(_factory.createInvoke(queryClass, "setParameter",
new ObjectType(queryClass),
new Type[] { parmType, arg.getType(), TEMPORAL_TYPE },
Constants.INVOKEINTERFACE));
}
}
}