本文整理汇总了Java中org.apache.bcel.classfile.Synthetic类的典型用法代码示例。如果您正苦于以下问题:Java Synthetic类的具体用法?Java Synthetic怎么用?Java Synthetic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Synthetic类属于org.apache.bcel.classfile包,在下文中一共展示了Synthetic类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visit
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
@Override
public void visit(JavaClass obj) {
String superclassName = obj.getSuperclassName();
isSynthetic = superclassName.equals("java.rmi.server.RemoteStub");
Attribute[] attributes = obj.getAttributes();
if (attributes != null) {
for (Attribute a : attributes) {
if (a instanceof Synthetic) {
isSynthetic = true;
}
}
}
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:15,代码来源:DumbMethods.java
示例2: isSynthetic
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
boolean isSynthetic(FieldOrMethod obj) {
Attribute[] a = obj.getAttributes();
for (Attribute aA : a)
if (aA instanceof Synthetic)
return true;
return false;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:8,代码来源:SerializableIdiom.java
示例3: isSynthetic
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
/**
* Methods marked with the "Synthetic" attribute do not appear in the source
* code
*/
private boolean isSynthetic(Method m) {
if ((m.getAccessFlags() & Constants.ACC_SYNTHETIC) != 0)
return true;
Attribute[] attrs = m.getAttributes();
for (Attribute attr : attrs) {
if (attr instanceof Synthetic)
return true;
}
return false;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:15,代码来源:FindUnrelatedTypesInGenericContainer.java
示例4: visitCode
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
@Override
public void visitCode(Code obj) {
try {
String methodName = getMethodName();
if (!methodName.equals("<init>") && !methodName.equals("clone")
&& ((getMethod().getAccessFlags() & (Constants.ACC_STATIC | Constants.ACC_SYNTHETIC)) == 0)) {
/*
* for some reason, access flags doesn't return Synthetic, so do
* this hocus pocus
*/
Attribute[] atts = getMethod().getAttributes();
for (Attribute att : atts) {
if (att.getClass().equals(Synthetic.class))
return;
}
byte[] codeBytes = obj.getCode();
if ((codeBytes.length == 0) || (codeBytes[0] != ALOAD_0))
return;
state = State.SEEN_NOTHING;
invokePC = 0;
super.visitCode(obj);
if ((state == State.SEEN_RETURN) && (invokePC != 0)) {
// Do this check late, as it is potentially expensive
Method superMethod = findSuperclassMethod(superclassName, getMethod());
if ((superMethod == null) || accessModifiersAreDifferent(getMethod(), superMethod))
return;
bugReporter.reportBug(new BugInstance(this, "USM_USELESS_SUBCLASS_METHOD", LOW_PRIORITY).addClassAndMethod(
this).addSourceLine(this, invokePC));
}
}
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
}
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:40,代码来源:UselessSubclassMethod.java
示例5: isSynthetic
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
private boolean isSynthetic(Method m) {
if (m.isSynthetic())
return true;
Attribute[] attrs = m.getAttributes();
for (Attribute attr : attrs) {
if (attr instanceof Synthetic)
return true;
}
return false;
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:11,代码来源:FindBadCast2.java
示例6: isSynthetic
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
public static boolean isSynthetic(FieldOrMethod m) {
if (m.isSynthetic())
return true;
for(Attribute a : m.getAttributes())
if (a instanceof Synthetic)
return true;
return false;
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:10,代码来源:BCELUtil.java
示例7: visitSynthetic
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
public void visitSynthetic(Synthetic obj){//vmspec2 4.7.6
checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
String name = ((ConstantUtf8) cp.getConstant(obj.getNameIndex())).getBytes();
if (! name.equals("Synthetic")){
throw new ClassConstraintException("The Synthetic attribute '"+tostring(obj)+"' is not correctly named 'Synthetic' but '"+name+"'.");
}
}
开发者ID:Hu6,项目名称:VestaClient,代码行数:8,代码来源:Pass2Verifier.java
示例8: visitSynthetic
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
@Override
public void visitSynthetic(Synthetic attribute) {
// printEndMethod(attribute);
}
开发者ID:shannah,项目名称:cn1,代码行数:5,代码来源:ClassToXmlvmProcess.java
示例9: visit
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
public void visit(Synthetic obj) {
visit((Attribute) obj);
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java
示例10: visitSynthetic
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
public void visitSynthetic(Synthetic obj) {
visit(obj);
}
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:4,代码来源:BetterVisitor.java
示例11: visitCode
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
@Override
public void visitCode(Code obj) {
try {
String methodName = getMethodName();
if (!methodName.equals("<init>") && !methodName.equals("clone")
&& ((getMethod().getAccessFlags() & (Constants.ACC_STATIC | Constants.ACC_SYNTHETIC)) == 0)) {
/*
* for some reason, access flags doesn't return Synthetic, so do
* this hocus pocus
*/
Attribute[] atts = getMethod().getAttributes();
for (Attribute att : atts) {
if (att.getClass().equals(Synthetic.class))
return;
}
byte[] codeBytes = obj.getCode();
if ((codeBytes.length == 0) || (codeBytes[0] != ALOAD_0))
return;
state = State.SEEN_NOTHING;
invokePC = 0;
super.visitCode(obj);
if ((state == State.SEEN_RETURN) && (invokePC != 0)) {
// Do this check late, as it is potentially expensive
Method superMethod = findSuperclassMethod(superclassName, getMethod());
if ((superMethod == null) || differentAttributes(getMethod(), superMethod)
|| getMethod().isProtected()
&& !samePackage(getDottedClassName(), superclassName))
return;
bugReporter.reportBug(new BugInstance(this, "USM_USELESS_SUBCLASS_METHOD", LOW_PRIORITY).addClassAndMethod(
this).addSourceLine(this, invokePC));
}
}
} catch (ClassNotFoundException cnfe) {
bugReporter.reportMissingClass(cnfe);
}
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:42,代码来源:UselessSubclassMethod.java
示例12: visitJavaClass
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
public void visitJavaClass(JavaClass obj){
Attribute[] atts = obj.getAttributes();
boolean foundSourceFile = false;
boolean foundInnerClasses = false;
// Is there an InnerClass referenced?
// This is a costly check; existing verifiers don't do it!
boolean hasInnerClass = new InnerClassDetector(jc).innerClassReferenced();
for (int i=0; i<atts.length; i++){
if ((! (atts[i] instanceof SourceFile)) &&
(! (atts[i] instanceof Deprecated)) &&
(! (atts[i] instanceof InnerClasses)) &&
(! (atts[i] instanceof Synthetic))){
addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of the ClassFile structure '"+tostring(obj)+"' is unknown and will therefore be ignored.");
}
if (atts[i] instanceof SourceFile){
if (foundSourceFile == false) {
foundSourceFile = true;
} else {
throw new ClassConstraintException("A ClassFile structure (like '"+tostring(obj)+"') may have no more than one SourceFile attribute."); //vmspec2 4.7.7
}
}
if (atts[i] instanceof InnerClasses){
if (foundInnerClasses == false) {
foundInnerClasses = true;
} else{
if (hasInnerClass){
throw new ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). More than one InnerClasses attribute was found.");
}
}
if (!hasInnerClass){
addMessage("No referenced Inner Class found, but InnerClasses attribute '"+tostring(atts[i])+"' found. Strongly suggest removal of that attribute.");
}
}
}
if (hasInnerClass && !foundInnerClasses){
//throw new ClassConstraintException("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). No InnerClasses attribute was found.");
//vmspec2, page 125 says it would be a constraint: but existing verifiers
//don't check it and javac doesn't satisfy it when it comes to anonymous
//inner classes
addMessage("A Classfile structure (like '"+tostring(obj)+"') must have exactly one InnerClasses attribute if at least one Inner Class is referenced (which is the case). No InnerClasses attribute was found.");
}
}
开发者ID:Hu6,项目名称:VestaClient,代码行数:48,代码来源:Pass2Verifier.java
示例13: visitField
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
public void visitField(Field obj){
if (jc.isClass()){
int maxone=0;
if (obj.isPrivate()) {
maxone++;
}
if (obj.isProtected()) {
maxone++;
}
if (obj.isPublic()) {
maxone++;
}
if (maxone > 1){
throw new ClassConstraintException("Field '"+tostring(obj)+"' must only have at most one of its ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC modifiers set.");
}
if (obj.isFinal() && obj.isVolatile()){
throw new ClassConstraintException("Field '"+tostring(obj)+"' must only have at most one of its ACC_FINAL, ACC_VOLATILE modifiers set.");
}
}
else{ // isInterface!
if (!obj.isPublic()){
throw new ClassConstraintException("Interface field '"+tostring(obj)+"' must have the ACC_PUBLIC modifier set but hasn't!");
}
if (!obj.isStatic()){
throw new ClassConstraintException("Interface field '"+tostring(obj)+"' must have the ACC_STATIC modifier set but hasn't!");
}
if (!obj.isFinal()){
throw new ClassConstraintException("Interface field '"+tostring(obj)+"' must have the ACC_FINAL modifier set but hasn't!");
}
}
if ((obj.getAccessFlags() & ~(ACC_PUBLIC|ACC_PRIVATE|ACC_PROTECTED|ACC_STATIC|ACC_FINAL|ACC_VOLATILE|ACC_TRANSIENT)) > 0){
addMessage("Field '"+tostring(obj)+"' has access flag(s) other than ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, ACC_TRANSIENT set (ignored).");
}
checkIndex(obj, obj.getNameIndex(), CONST_Utf8);
String name = obj.getName();
if (! validFieldName(name)){
throw new ClassConstraintException("Field '"+tostring(obj)+"' has illegal name '"+obj.getName()+"'.");
}
// A descriptor is often named signature in BCEL
checkIndex(obj, obj.getSignatureIndex(), CONST_Utf8);
String sig = ((ConstantUtf8) (cp.getConstant(obj.getSignatureIndex()))).getBytes(); // Field or Method signature(=descriptor)
try{
Type.getType(sig); /* Don't need the return value */
}
catch (ClassFormatException cfe){
throw new ClassConstraintException("Illegal descriptor (==signature) '"+sig+"' used by '"+tostring(obj)+"'.");
}
String nameanddesc = (name+sig);
if (field_names_and_desc.contains(nameanddesc)){
throw new ClassConstraintException("No two fields (like '"+tostring(obj)+"') are allowed have same names and descriptors!");
}
if (field_names.contains(name)){
addMessage("More than one field of name '"+name+"' detected (but with different type descriptors). This is very unusual.");
}
field_names_and_desc.add(nameanddesc);
field_names.add(name);
Attribute[] atts = obj.getAttributes();
for (int i=0; i<atts.length; i++){
if ((! (atts[i] instanceof ConstantValue)) &&
(! (atts[i] instanceof Synthetic)) &&
(! (atts[i] instanceof Deprecated))){
addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of Field '"+tostring(obj)+"' is unknown and will therefore be ignored.");
}
if (! (atts[i] instanceof ConstantValue)){
addMessage("Attribute '"+tostring(atts[i])+"' as an attribute of Field '"+tostring(obj)+"' is not a ConstantValue and is therefore only of use for debuggers and such.");
}
}
}
开发者ID:Hu6,项目名称:VestaClient,代码行数:79,代码来源:Pass2Verifier.java
示例14: visitSynthetic
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
public void visitSynthetic(Synthetic obj) {
tostring = toString(obj);
}
开发者ID:Hu6,项目名称:VestaClient,代码行数:4,代码来源:StringRepresentation.java
示例15: visitSynthetic
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
public void visitSynthetic(Synthetic attribute) {
}
开发者ID:jesusc,项目名称:eclectic,代码行数:3,代码来源:DecompilingVisitor.java
示例16: visitSynthetic
import org.apache.bcel.classfile.Synthetic; //导入依赖的package包/类
public void visitSynthetic(Synthetic attribute) { printEndMethod(attribute); }
开发者ID:diana-hep,项目名称:root4j,代码行数:2,代码来源:JasminVisitor.java
注:本文中的org.apache.bcel.classfile.Synthetic类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论