Class Pass2Verifier.InnerClassDetector

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

private static final 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 Details

    • hasInnerClass

      private boolean hasInnerClass
    • jc

      private final JavaClass jc
    • cp

      private final ConstantPool cp
  • Constructor Details

    • InnerClassDetector

      public InnerClassDetector(JavaClass javaClass)
      Constructs an InnerClassDetector working on the JavaClass _jc.
  • Method Details

    • innerClassReferenced

      public boolean innerClassReferenced()
      Returns if the JavaClass this InnerClassDetector is working on has an Inner Class reference in its constant pool.
      Returns:
      Whether 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