data.writeShort(nClassAttrs); if (env.debug_source()) { data.writeShort(tab.index("SourceFile")); data.writeInt(2); data.writeShort(tab.index(sourceFile)); } if (this.isDeprecated()) { data.writeShort(tab.index("Deprecated")); data.writeInt(0); } if (this.isSynthetic()) { data.writeShort(tab.index("Synthetic")); data.writeInt(0); } // JCOV if (env.coverage()) { data.writeShort(tab.index("AbsoluteSourcePath")); data.writeInt(2); data.writeShort(tab.index(absoluteSourcePath)); data.writeShort(tab.index("TimeStamp")); data.writeInt(8); data.writeLong(timeStamp); }// end JCOV if (innerClasses.size() > 0) { data.writeShort(tab.index("InnerClasses")); data.writeInt(2 + 2*4*innerClasses.size()); data.writeShort(innerClasses.size()); for (Enumeration e = innerClasses.elements() ; e.hasMoreElements() ; ) { // For each inner class name transformation, we have a record // with the following fields: // // u2 inner_class_info_index; // CONSTANT_Class_info index // u2 outer_class_info_index; // CONSTANT_Class_info index // u2 inner_name_index; // CONSTANT_Utf8_info index // u2 inner_class_access_flags; // access_flags bitmask // // The spec states that outer_class_info_index is 0 iff // the inner class is not a member of its enclosing class (i.e. // it is a local or anonymous class). The spec also states // that if a class is anonymous then inner_name_index should // be 0. // // See also the initInnerClasses() method in BinaryClass.java. // Generate inner_class_info_index. ClassDefinition inner = (ClassDefinition)e.nextElement(); data.writeShort(tab.index(inner.getClassDeclaration())); // Generate outer_class_info_index. // // Checking isLocal() should probably be enough here, // but the check for isAnonymous is added for good // measure. if (inner.isLocal() || inner.isAnonymous()) { data.writeShort(0); } else { // Query: what about if inner.isInsideLocal()? // For now we continue to generate a nonzero // outer_class_info_index. ClassDefinition outer = inner.getOuterClass(); data.writeShort(tab.index(outer.getClassDeclaration())); } // Generate inner_name_index. Identifier inner_name = inner.getLocalName(); if (inner_name == idNull) { if (!inner.isAnonymous()) { throw new CompilerError("compileClass(), anonymous"); } data.writeShort(0); } else { data.writeShort(tab.index(inner_name.toString())); } // Generate inner_class_access_flags. int imods = inner.getInnerClassMember().getModifiers() & ACCM_INNERCLASS; // Certain modifiers are implied for nested types. // See rules 1, 2, 3a, and 3b enumerated above. // All of these rules are implemented in 'BatchParser.beginClass', // but are verified here. if (inner.isInterface()) { // Rules 1 and 2. assertModifiers(imods, M_ABSTRACT | M_STATIC); } if (inner.getOuterClass().isInterface()) { // Rules 3a and 3b. imods &= ~(M_PRIVATE | M_PROTECTED); // error recovery assertModifiers(imods, M_PUBLIC | M_STATIC); } data.writeShort(imods); if (env.dumpModifiers()) { Identifier fn = inner.getInnerClassMember().getName(); Identifier nm = Identifier.lookup(fn.getQualifier(), fn.getFlatName()); System.out.println("INNERCLASS " + nm); System.out.println("---" + classModifierString(imods)); } } } // Cleanup data.flush(); tab = null; // JCOV // generate coverage data if (env.covdata()) { Assembler CovAsm = new Assembler(); CovAsm.GenVecJCov(env, (ClassDefinition)this, timeStamp); }// end JCOV } /** * Print out the dependencies for this class (-xdepend) option */ public void printClassDependencies(Environment env) { // Only do this if the -xdepend flag is on if ( toplevelEnv.print_dependencies() ) { // Name of java source file this class was in (full path) // e.g. /home/ohair/Test.java String src = ((ClassFile)getSource()).getAbsoluteName(); // Class name, fully qualified // e.g. "java.lang.Object" or "FooBar" or "sun.tools.javac.Main" // Inner class names must be mangled, as ordinary '.' qualification // is used internally where the spec requires '$' separators. // String className = getName().toString(); String className = Type.mangleInnerType(getName()).toString(); // Line number where class starts in the src file long startLine = getWhere() >> WHEREOFFSETBITS; // Line number where class ends in the src file (not used yet) long endLine = getEndPosition() >> WHEREOFFSETBITS; // First line looks like: // CLASS:src,startLine,endLine,className System.out.println( "CLASS:" + src + "," + startLine + "," + endLine + "," + className); // For each class this class is dependent on: // CLDEP:className1,className2 // where className1 is the name of the class we are in, and // classname2 is the name of the class className1 // is dependent on. for(Enumeration e = deps.elements(); e.hasMoreElements(); ) { ClassDeclaration data = (ClassDeclaration) e.nextElement(); // Mangle name of class dependend on. String depName = Type.mangleInnerType(data.getName()).toString(); env.output("CLDEP:" + className + "," + depName); } } }}Lines 2501–2674 of 2674. Previous lines
data.writeShort(nClassAttrs); if (env.debug_source()) { data.writeShort(tab.index("SourceFile")); data.writeInt(2); data.writeShort(tab.index(sourceFile)); } if (this.isDeprecated()) { data.writeShort(tab.index("Deprecated")); data.writeInt(0); } if (this.isSynthetic()) { data.writeShort(tab.index("Synthetic")); data.writeInt(0); } // JCOV if (env.coverage()) { data.writeShort(tab.index("AbsoluteSourcePath")); data.writeInt(2); data.writeShort(tab.index(absoluteSourcePath)); data.writeShort(tab.index("TimeStamp")); data.writeInt(8); data.writeLong(timeStamp); } // end JCOV if (innerClasses.size() > 0) { data.writeShort(tab.index("InnerClasses")); data.writeInt(2 + 2*4*innerClasses.size()); data.writeShort(innerClasses.size()); for (Enumeration e = innerClasses.elements() ; e.hasMoreElements() ; ) { // For each inner class name transformation, we have a record // with the following fields: // // u2 inner_class_info_index; // CONSTANT_Class_info index // u2 outer_class_info_index; // CONSTANT_Class_info index // u2 inner_name_index; // CONSTANT_Utf8_info index // u2 inner_class_access_flags; // access_flags bitmask // // The spec states that outer_class_info_index is 0 iff // the inner class is not a member of its enclosing class (i.e. // it is a local or anonymous class). The spec also states // that if a class is anonymous then inner_name_index should // be 0. // // See also the initInnerClasses() method in BinaryClass.java. // Generate inner_class_info_index. ClassDefinition inner = (ClassDefinition)e.nextElement(); data.writeShort(tab.index(inner.getClassDeclaration())); // Generate outer_class_info_index. // // Checking isLocal() should probably be enough here, // but the check for isAnonymous is added for good // measure. if (inner.isLocal() || inner.isAnonymous()) { data.writeShort(0); } else { // Query: what about if inner.isInsideLocal()? // For now we continue to generate a nonzero // outer_class_info_index. ClassDefinition outer = inner.getOuterClass(); data.writeShort(tab.index(outer.getClassDeclaration())); } // Generate inner_name_index. Identifier inner_name = inner.getLocalName(); if (inner_name == idNull) { if (!inner.isAnonymous()) { throw new CompilerError("compileClass(), anonymous"); } data.writeShort(0); } else { data.writeShort(tab.index(inner_name.toString())); } // Generate inner_class_access_flags. int imods = inner.getInnerClassMember().getModifiers() & ACCM_INNERCLASS; // Certain modifiers are implied for nested types. // See rules 1, 2, 3a, and 3b enumerated above. // All of these rules are implemented in 'BatchParser.beginClass', // but are verified here. if (inner.isInterface()) { // Rules 1 and 2. assertModifiers(imods, M_ABSTRACT | M_STATIC); } if (inner.getOuterClass().isInterface()) { // Rules 3a and 3b. imods &= ~(M_PRIVATE | M_PROTECTED); // error recovery assertModifiers(imods, M_PUBLIC | M_STATIC); } data.writeShort(imods); if (env.dumpModifiers()) { Identifier fn = inner.getInnerClassMember().getName(); Identifier nm = Identifier.lookup(fn.getQualifier(), fn.getFlatName()); System.out.println("INNERCLASS " + nm); System.out.println("---" + classModifierString(imods)); } } } // Cleanup data.flush(); tab = null; // JCOV // generate coverage data if (env.covdata()) { Assembler CovAsm = new Assembler(); CovAsm.GenVecJCov(env, (ClassDefinition)this, timeStamp); } // end JCOV } /** * Print out the dependencies for this class (-xdepend) option */ public void printClassDependencies(Environment env) { // Only do this if the -xdepend flag is on if ( toplevelEnv.print_dependencies() ) { // Name of java source file this class was in (full path) // e.g. /home/ohair/Test.java String src = ((ClassFile)getSource()).getAbsoluteName(); // Class name, fully qualified // e.g. "java.lang.Object" or "FooBar" or "sun.tools.javac.Main" // Inner class names must be mangled, as ordinary '.' qualification // is used internally where the spec requires '$' separators. // String className = getName().toString(); String className = Type.mangleInnerType(getName()).toString(); // Line number where class starts in the src file long startLine = getWhere() >> WHEREOFFSETBITS; // Line number where class ends in the src file (not used yet) long endLine = getEndPosition() >> WHEREOFFSETBITS; // First line looks like: // CLASS:src,startLine,endLine,className System.out.println( "CLASS:" + src + "," + startLine + "," + endLine + "," + className); // For each class this class is dependent on: // CLDEP:className1,className2 // where className1 is the name of the class we are in, and // classname2 is the name of the class className1 // is dependent on. for(Enumeration e = deps.elements(); e.hasMoreElements(); ) { ClassDeclaration data = (ClassDeclaration) e.nextElement(); // Mangle name of class dependend on. String depName = Type.mangleInnerType(data.getName()).toString(); env.output("CLDEP:" + className + "," + depName); } } } }