本文整理汇总了Java中org.apache.bcel.classfile.ConstantClass.getBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ConstantClass.getBytes方法的具体用法?Java ConstantClass.getBytes怎么用?Java ConstantClass.getBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.ConstantClass
的用法示例。
在下文中一共展示了ConstantClass.getBytes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOuterClass
import org.apache.bcel.classfile.ConstantClass; //导入方法依赖的package包/类
/**
* Determine the outer class of obj.
*
* @param obj
* @return JavaClass for outer class, or null if obj is not an outer class
* @throws ClassNotFoundException
*/
@CheckForNull
public static JavaClass getOuterClass(JavaClass obj) throws ClassNotFoundException {
for (Attribute a : obj.getAttributes())
if (a instanceof InnerClasses) {
for (InnerClass ic : ((InnerClasses) a).getInnerClasses()) {
if (obj.getClassNameIndex() == ic.getInnerClassIndex()) {
// System.out.println("Outer class is " +
// ic.getOuterClassIndex());
ConstantClass oc = (ConstantClass) obj.getConstantPool().getConstant(ic.getOuterClassIndex());
String ocName = oc.getBytes(obj.getConstantPool());
return Repository.lookupClass(ocName);
}
}
}
return null;
}
示例2: visit
import org.apache.bcel.classfile.ConstantClass; //导入方法依赖的package包/类
@Override
public void visit(ConstantPool pool) {
for (Constant constant : pool.getConstantPool()) {
if (constant instanceof ConstantClass) {
ConstantClass cc = (ConstantClass) constant;
@SlashedClassName String className = cc.getBytes(pool);
if (className.equals("java/util/Calendar") || className.equals("java/text/DateFormat")) {
sawDateClass = true;
break;
}
try {
ClassDescriptor cDesc = DescriptorFactory.createClassDescriptor(className);
if (subtypes2.isSubtype(cDesc, calendarType) || subtypes2.isSubtype(cDesc, dateFormatType)) {
sawDateClass = true;
break;
}
} catch (ClassNotFoundException e) {
reporter.reportMissingClass(e);
}
}
}
}
示例3: visitLDC
import org.apache.bcel.classfile.ConstantClass; //导入方法依赖的package包/类
@Override
public void visitLDC(LDC obj) {
Object constantValue = obj.getValue(cpg);
ValueNumber value;
if (constantValue instanceof ConstantClass) {
ConstantClass constantClass = (ConstantClass) constantValue;
String className = constantClass.getBytes(cpg.getConstantPool());
value = factory.getClassObjectValue(className);
} else {
value = constantValueMap.get(constantValue);
if (value == null) {
value = factory.createFreshValue(ValueNumber.CONSTANT_VALUE);
constantValueMap.put(constantValue, value);
// Keep track of String constants
if (constantValue instanceof String) {
stringConstantMap.put(value, (String) constantValue);
}
}
}
getFrame().pushValue(value);
}
示例4: getOuterClass
import org.apache.bcel.classfile.ConstantClass; //导入方法依赖的package包/类
/**
* Determine the outer class of obj.
*
* @param obj
* @return JavaClass for outer class, or null if obj is not an outer class
* @throws ClassNotFoundException
*/
@CheckForNull
public static JavaClass getOuterClass(JavaClass obj) throws ClassNotFoundException {
for (Attribute a : obj.getAttributes())
if (a instanceof InnerClasses) {
for (InnerClass ic : ((InnerClasses) a).getInnerClasses()) {
if (obj.getClassNameIndex() == ic.getInnerClassIndex()) {
// System.out.println("Outer class is " +
// ic.getOuterClassIndex());
ConstantClass oc = (ConstantClass) obj.getConstantPool().getConstant(ic.getOuterClassIndex());
String ocName = oc.getBytes(obj.getConstantPool());
return Repository.lookupClass(ocName);
}
}
}
return null;
}
示例5: visitConstantClass
import org.apache.bcel.classfile.ConstantClass; //导入方法依赖的package包/类
@Override
public void visitConstantClass(ConstantClass obj) {
String name1 = obj.getBytes(this.cp);
if (this.parser.isDebug()) {
this.parser.debug("visitConstantClass: obj.getBytes(this.cp) = " + name1);
}
String name = ParseTool.slashesToDots(name1);
name = ParseTool.getType(name);
if (name != null && name.length() > 0 && !jClass.getDetail().getSupers().contains(name)) {
jClass.getDetail().addVariableType(name);
if (this.parser.isDebug()) {
this.parser.debug("visitConstantClass: type = " + name);
}
}
}
示例6: getItem
import org.apache.bcel.classfile.ConstantClass; //导入方法依赖的package包/类
static private Item getItem(StackMapType t) {
switch (t.getType()) {
case Constants.ITEM_Double:
return Item.typeOnly("D");
case Constants.ITEM_Float:
return Item.typeOnly("F");
case Constants.ITEM_Integer:
return Item.typeOnly("I");
case Constants.ITEM_Long:
return Item.typeOnly("J");
case Constants.ITEM_Bogus:
case Constants.ITEM_NewObject:
return Item.typeOnly("Ljava/lang/Object;");
case Constants.ITEM_Null:
Item it = new Item();
it.setSpecialKind(Item.TYPE_ONLY);
return it;
case Constants.ITEM_InitObject:
return Item.typeOnly("Ljava/lang/Object;");
case Constants.ITEM_Object:
int index = t.getIndex();
ConstantClass c = (ConstantClass) t.getConstantPool().getConstant(index);
String name = c.getBytes(t.getConstantPool());
if (name.charAt(0) != '[') name = "L" + name + ";";
return Item.typeOnly(name);
default:
throw new IllegalArgumentException("Bad item type: " + t.getType());
}
}
示例7: visitConstantClass
import org.apache.bcel.classfile.ConstantClass; //导入方法依赖的package包/类
@Override
public void visitConstantClass(ConstantClass constantClass) {
final ConstantPool cp = javaClass.getConstantPool();
String dependency = constantClass.getBytes(cp);
// handle array dependencies
// if this is an array dependency remove identifiers
if (dependency.startsWith(BINARY_ARRAY_ID_PREFIX)) {
dependency = dependency.replaceAll(ARRAY_ID_PREFIX_REGEX, "");
dependency = dependency.replaceAll(BINARY_ARRAY_ID_SUFFIX, "");
}
// handle binary type notations
if (dependency.startsWith(BINARY_TYPE_PREFIX)) {
dependency = dependency.replaceAll(TYPE_PREFIX_REGEX, "");
}
// because for some reason BCEL returns dependencies like this:
//
// com/something/Class
//
// which is odd
// TODO check if there is a way to return dependencies dot delimited
dependency = dependency.replaceAll("/", ".");
foundDependencies.add(new ClassName(dependency));
}