org.apache.bcel.verifier.statics
Class Pass2Verifier.InnerClassDetector

java.lang.Object
  extended by org.apache.bcel.classfile.EmptyVisitor
      extended by org.apache.bcel.verifier.statics.Pass2Verifier.InnerClassDetector
All Implemented Interfaces:
Visitor
Enclosing class:
Pass2Verifier

private static class Pass2Verifier.InnerClassDetector
extends EmptyVisitor

This class serves for finding out if a given JavaClass' ConstantPool references an Inner Class. The Java Virtual Machine Specification, Second Edition is not very precise about when an "InnerClasses" attribute has to appear. However, it states that there has to be exactly one InnerClasses attribute in the ClassFile structure if the constant pool of a class or interface refers to any class or interface "that is not a member of a package". Sun does not mean "member of the default package". In "Inner Classes Specification" they point out how a "bytecode name" is derived so one has to deduce what a class name of a class "that is not a member of a package" looks like: there is at least one character in the byte- code name that cannot be part of a legal Java Language Class name (and not equal to '/'). This assumption is wrong as the delimiter is '$' for which Character.isJavaIdentifierPart() == true. Hence, you really run into trouble if you have a toplevel class called "A$XXX" and another toplevel class called "A" with in inner class called "XXX". JustIce cannot repair this; please note that existing verifiers at this time even fail to detect missing InnerClasses attributes in pass 2.


Field Summary
private  ConstantPool cp
           
private  boolean hasInnerClass
           
private  JavaClass jc
           
 
Constructor Summary
Pass2Verifier.InnerClassDetector(JavaClass _jc)
          Constructs an InnerClassDetector working on the JavaClass _jc.
 
Method Summary
 boolean innerClassReferenced()
          Returns if the JavaClass this InnerClassDetector is working on has an Inner Class reference in its constant pool.
 void visitConstantClass(ConstantClass obj)
          This method casually visits ConstantClass references.
 
Methods inherited from class org.apache.bcel.classfile.EmptyVisitor
visitCode, visitCodeException, visitConstantDouble, visitConstantFieldref, visitConstantFloat, visitConstantInteger, visitConstantInterfaceMethodref, visitConstantLong, visitConstantMethodref, visitConstantNameAndType, visitConstantPool, visitConstantString, visitConstantUtf8, visitConstantValue, visitDeprecated, visitExceptionTable, visitField, visitInnerClass, visitInnerClasses, visitJavaClass, visitLineNumber, visitLineNumberTable, visitLocalVariable, visitLocalVariableTable, visitMethod, visitSignature, visitSourceFile, visitStackMap, visitStackMapEntry, visitSynthetic, visitUnknown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hasInnerClass

private boolean hasInnerClass

jc

private JavaClass jc

cp

private ConstantPool cp
Constructor Detail

Pass2Verifier.InnerClassDetector

public Pass2Verifier.InnerClassDetector(JavaClass _jc)
Constructs an InnerClassDetector working on the JavaClass _jc.

Method Detail

innerClassReferenced

public boolean innerClassReferenced()
Returns if the JavaClass this InnerClassDetector is working on has an Inner Class reference in its constant pool.


visitConstantClass

public void visitConstantClass(ConstantClass obj)
This method casually visits ConstantClass references.

Specified by:
visitConstantClass in interface Visitor
Overrides:
visitConstantClass in class EmptyVisitor