本文整理汇总了Java中com.sun.org.apache.bcel.internal.Repository类的典型用法代码示例。如果您正苦于以下问题:Java Repository类的具体用法?Java Repository怎么用?Java Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Repository类属于com.sun.org.apache.bcel.internal包,在下文中一共展示了Repository类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: referencesClass
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
/**
* If "this" doesn't reference a class, it references an interface
* or a non-existant entity.
*/
public boolean referencesClass(){
JavaClass jc = Repository.lookupClass(class_name);
if (jc == null)
return false;
else
return jc.isClass();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:ObjectType.java
示例2: referencesInterface
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
/**
* If "this" doesn't reference an interface, it references a class
* or a non-existant entity.
*/
public boolean referencesInterface(){
JavaClass jc = Repository.lookupClass(class_name);
if (jc == null)
return false;
else
return !jc.isClass();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:ObjectType.java
示例3: accessibleTo
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
/**
* Java Virtual Machine Specification edition 2, 5.4.4 Access Control
*/
public boolean accessibleTo(ObjectType accessor) {
JavaClass jc = Repository.lookupClass(class_name);
if(jc.isPublic()) {
return true;
} else {
JavaClass acc = Repository.lookupClass(accessor.class_name);
return acc.getPackageName().equals(jc.getPackageName());
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:ObjectType.java
示例4: _main
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
/** Default _main method
*/
public static void _main(String[] argv) throws Exception {
JavaClass java_class;
String name = argv[0];
if((java_class = Repository.lookupClass(name)) == null)
java_class = new ClassParser(name).parse(); // May throw IOException
BCELifier bcelifier = new BCELifier(java_class, System.out);
bcelifier.start();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:BCELifier.java
示例5: referencesClass
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
/**
* If "this" doesn't reference a class, it references an interface
* or a non-existant entity.
* @deprecated (since 6.0) this method returns an inaccurate result
* if the class or interface referenced cannot
* be found: use referencesClassExact() instead
*/
@Deprecated
public boolean referencesClass() {
try {
final JavaClass jc = Repository.lookupClass(class_name);
return jc.isClass();
} catch (final ClassNotFoundException e) {
return false;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:ObjectType.java
示例6: referencesInterface
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
/**
* If "this" doesn't reference an interface, it references a class
* or a non-existant entity.
* @deprecated (since 6.0) this method returns an inaccurate result
* if the class or interface referenced cannot
* be found: use referencesInterfaceExact() instead
*/
@Deprecated
public boolean referencesInterface() {
try {
final JavaClass jc = Repository.lookupClass(class_name);
return !jc.isClass();
} catch (final ClassNotFoundException e) {
return false;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:ObjectType.java
示例7: subclassOf
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
/**
* Return true if this type is a subclass of given ObjectType.
* @throws ClassNotFoundException if any of this class's superclasses
* can't be found
*/
public boolean subclassOf( final ObjectType superclass ) throws ClassNotFoundException {
if (this.referencesInterfaceExact() || superclass.referencesInterfaceExact()) {
return false;
}
return Repository.instanceOf(this.class_name, superclass.class_name);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ObjectType.java
示例8: accessibleTo
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
/**
* Java Virtual Machine Specification edition 2, 5.4.4 Access Control
* @throws ClassNotFoundException if the class referenced by this type
* can't be found
*/
public boolean accessibleTo( final ObjectType accessor ) throws ClassNotFoundException {
final JavaClass jc = Repository.lookupClass(class_name);
if (jc.isPublic()) {
return true;
}
final JavaClass acc = Repository.lookupClass(accessor.class_name);
return acc.getPackageName().equals(jc.getPackageName());
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ObjectType.java
示例9: getJavaClass
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
static JavaClass getJavaClass(final String name) throws ClassNotFoundException, IOException {
JavaClass java_class;
if ((java_class = Repository.lookupClass(name)) == null) {
java_class = new ClassParser(name).parse(); // May throw IOException
}
return java_class;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:BCELifier.java
示例10: subclassOf
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
public boolean subclassOf(ObjectType superclass){
if (this.referencesInterface() || superclass.referencesInterface())
return false;
return Repository.instanceOf(this.class_name, superclass.class_name);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:ObjectType.java
示例11: firstCommonSuperclass
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
/**
* This commutative operation returns the first common superclass (narrowest ReferenceType
* referencing a class, not an interface).
* If one of the types is a superclass of the other, the former is returned.
* If "this" is Type.NULL, then t is returned.
* If t is Type.NULL, then "this" is returned.
* If "this" equals t ['this.equals(t)'] "this" is returned.
* If "this" or t is an ArrayType, then Type.OBJECT is returned.
* If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
* If not all of the two classes' superclasses cannot be found, "null" is returned.
* See the JVM specification edition 2, "4.9.2 The Bytecode Verifier".
*
* @deprecated use getFirstCommonSuperclass(ReferenceType t) which has
* slightly changed semantics.
*/
public ReferenceType firstCommonSuperclass(ReferenceType t) {
if (this.equals(Type.NULL)) return t;
if (t.equals(Type.NULL)) return this;
if (this.equals(t)) return this;
/*
* TODO: Above sounds a little arbitrary. On the other hand, there is
* no object referenced by Type.NULL so we can also say all the objects
* referenced by Type.NULL were derived from java.lang.Object.
* However, the Java Language's "instanceof" operator proves us wrong:
* "null" is not referring to an instance of java.lang.Object :)
*/
if ((this instanceof ArrayType) || (t instanceof ArrayType))
return Type.OBJECT;
// TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface()) ||
((t instanceof ObjectType) && ((ObjectType) t).referencesInterface()))
return Type.OBJECT;
// TODO: The above line is correct comparing to the vmspec2. But one could
// make class file verification a bit stronger here by using the notion of
// superinterfaces or even castability or assignment compatibility.
// this and t are ObjectTypes, see above.
ObjectType thiz = (ObjectType) this;
ObjectType other = (ObjectType) t;
JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName());
JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
if ((thiz_sups == null) || (other_sups == null)) {
return null;
}
// Waaahh...
JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1];
JavaClass[] t_sups = new JavaClass[other_sups.length + 1];
System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length);
System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length);
this_sups[0] = Repository.lookupClass(thiz.getClassName());
t_sups[0] = Repository.lookupClass(other.getClassName());
for (int i = 0; i < t_sups.length; i++) {
for (int j = 0; j < this_sups.length; j++) {
if (this_sups[j].equals(t_sups[i])) return new ObjectType(this_sups[j].getClassName());
}
}
// Huh? Did you ask for Type.OBJECT's superclass??
return null;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:67,代码来源:ReferenceType.java
示例12: firstCommonSuperclass
import com.sun.org.apache.bcel.internal.Repository; //导入依赖的package包/类
/**
* This commutative operation returns the first common superclass (narrowest ReferenceType
* referencing a class, not an interface).
* If one of the types is a superclass of the other, the former is returned.
* If "this" is Type.NULL, then t is returned.
* If t is Type.NULL, then "this" is returned.
* If "this" equals t ['this.equals(t)'] "this" is returned.
* If "this" or t is an ArrayType, then Type.OBJECT is returned.
* If "this" or t is a ReferenceType referencing an interface, then Type.OBJECT is returned.
* If not all of the two classes' superclasses cannot be found, "null" is returned.
* See the JVM specification edition 2, "4.9.2 The Bytecode Verifier".
*
* @deprecated use getFirstCommonSuperclass(ReferenceType t) which has
* slightly changed semantics.
* @throws ClassNotFoundException on failure to find superclasses of this
* type, or the type passed as a parameter
*/
@Deprecated
public ReferenceType firstCommonSuperclass( final ReferenceType t ) throws ClassNotFoundException {
if (this.equals(Type.NULL)) {
return t;
}
if (t.equals(Type.NULL)) {
return this;
}
if (this.equals(t)) {
return this;
/*
* TODO: Above sounds a little arbitrary. On the other hand, there is
* no object referenced by Type.NULL so we can also say all the objects
* referenced by Type.NULL were derived from java.lang.Object.
* However, the Java Language's "instanceof" operator proves us wrong:
* "null" is not referring to an instance of java.lang.Object :)
*/
}
if ((this instanceof ArrayType) || (t instanceof ArrayType)) {
return Type.OBJECT;
// TODO: Is there a proof of OBJECT being the direct ancestor of every ArrayType?
}
if (((this instanceof ObjectType) && ((ObjectType) this).referencesInterface())
|| ((t instanceof ObjectType) && ((ObjectType) t).referencesInterface())) {
return Type.OBJECT;
// TODO: The above line is correct comparing to the vmspec2. But one could
// make class file verification a bit stronger here by using the notion of
// superinterfaces or even castability or assignment compatibility.
}
// this and t are ObjectTypes, see above.
final ObjectType thiz = (ObjectType) this;
final ObjectType other = (ObjectType) t;
final JavaClass[] thiz_sups = Repository.getSuperClasses(thiz.getClassName());
final JavaClass[] other_sups = Repository.getSuperClasses(other.getClassName());
if ((thiz_sups == null) || (other_sups == null)) {
return null;
}
// Waaahh...
final JavaClass[] this_sups = new JavaClass[thiz_sups.length + 1];
final JavaClass[] t_sups = new JavaClass[other_sups.length + 1];
System.arraycopy(thiz_sups, 0, this_sups, 1, thiz_sups.length);
System.arraycopy(other_sups, 0, t_sups, 1, other_sups.length);
this_sups[0] = Repository.lookupClass(thiz.getClassName());
t_sups[0] = Repository.lookupClass(other.getClassName());
for (final JavaClass t_sup : t_sups) {
for (final JavaClass this_sup : this_sups) {
if (this_sup.equals(t_sup)) {
return ObjectType.getInstance(this_sup.getClassName());
}
}
}
// Huh? Did you ask for Type.OBJECT's superclass??
return null;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:72,代码来源:ReferenceType.java
注:本文中的com.sun.org.apache.bcel.internal.Repository类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论