/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* WARNING: The contents of this source file are not part of any
* supported API. Code that depends on them does so at its own risk:
* they are subject to change or removal without notice.
*/
public final
private boolean haveLoadedNested = false;
/**
* Constructor
*/
this.dependencies = dependencies;
this.superClass = superClass;
this.interfaces = interfaces;
}
/**
* Flags used by basicCheck() to avoid duplicate calls.
* (Part of fix for 4105911)
*/
private boolean basicCheckDone = false;
private boolean basicChecking = false;
/**
* Ready a BinaryClass for further checking. Note that, until recently,
* BinaryClass relied on the default basicCheck() provided by
* ClassDefinition. The definition here has been added to ensure that
* the information generated by collectInheritedMethods is available
* for BinaryClasses.
*/
// We need to guard against duplicate calls to basicCheck(). They
// can lead to calling collectInheritedMethods() for this class
// from within a previous call to collectInheritedMethods() for
// this class. That is not allowed.
// (Part of fix for 4105911)
if (basicChecking || basicCheckDone) {
return;
}
basicChecking = true;
super.basicCheck(env);
// Collect inheritance information.
if (doInheritanceChecks) {
}
basicCheckDone = true;
basicChecking = false;
}
/**
* Load a binary class
*/
}
// Read the header
if (magic != JAVA_MAGIC) {
}
if (version < JAVA_MIN_SUPPORTED_VERSION) {
throw new ClassFormatError(
"javac.err.version.too.old",
} else if ((version > JAVA_MAX_SUPPORTED_VERSION)
throw new ClassFormatError(
"javac.err.version.too.recent",
}
// Read the constant pool
// The dependencies of this class
// Read modifiers
// Read the class name - from JVM 4.1 ClassFile.this_class
// Read the super class name (may be null) - from JVM 4.1 ClassFile.super_class
// Read the interface names - from JVM 4.1 ClassFile.interfaces_count
// JVM 4.1 ClassFile.interfaces[]
}
// Allocate the class
// Add any additional dependencies
// Read the fields
for (int i = 0 ; i < nfields ; i++) {
// JVM 4.5 field_info.access_flags
// JVM 4.5 field_info.name_index
// JVM 4.5 field_info.descriptor_index
}
// Read the methods
for (int i = 0 ; i < nmethods ; i++) {
// JVM 4.6 method_info.access_flags
// JVM 4.6 method_info.name_index
// JVM 4.6 method_info.descriptor_index
}
// Read the class attributes
// See if the SourceFile is known
// JVM 4.7.2 SourceFile_attribute.sourcefile_index
}
// See if the Documentation is know
}
// Was it compiled as deprecated?
c.modifiers |= M_DEPRECATED;
}
// Was it synthesized by the compiler?
c.modifiers |= M_SYNTHETIC;
}
return c;
}
/**
* Called when an environment ties a binary definition to a declaration.
* At this point, auxiliary definitions may be loaded.
*/
}
// Sanity check.
if (haveLoadedNested) {
// Duplicate calls most likely should not occur, but they do
// in javap. Be tolerant of them for the time being.
// throw new CompilerError("multiple loadNested");
return;
}
haveLoadedNested = true;
// Read class-nesting information.
try {
byte data[];
}
} catch (IOException ee) {
// The inner classes attribute is not well-formed.
// It may, for example, contain no data. Report this.
// We used to throw a CompilerError here (bug 4095108).
if (tracing)
}
}
byte data[],
int flags) throws IOException {
for (int i = 0; i < nrec; i++) {
// 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.
//
// Prior to jdk1.2, javac did not implement the spec. Instead
// it <em>always</em> set outer_class_info_index to the
// enclosing outer class and if the class was anonymous,
// it set inner_name_index to be the index of a CONSTANT_Utf8
// entry containing the null string "" (idNull). This code is
// designed to handle either kind of class file.
//
// See also the compileClass() method in SourceClass.java.
// Read in the inner_class_info
// InnerClasses_attribute.classes.inner_class_info_index
// could check for zero.
// Read in the outer_class_info. Note that the index will be
// zero if the class is "not a member".
// InnerClasses_attribute.classes.outer_class_info_index
if (outer_index != 0) {
}
// Read in the inner_name_index. This may be zero. An anonymous
// class will either have an inner_nm_index of zero (as the spec
// dictates) or it will have an inner_nm of idNull (for classes
// generated by pre-1.2 compilers). Handle both.
// InnerClasses_attribute.classes.inner_name_index
if (inner_nm_index != 0) {
}
// Read in the modifiers for the inner class.
// InnerClasses_attribute.classes.inner_name_index
// Is the class accessible?
// The old code checked for
//
// (!inner_nm.equals(idNull) && (mods & M_PRIVATE) == 0)
//
// which we will preserve to keep it working for class files
// generated by 1.1 compilers. In addition we check for
//
// (outer != null)
//
// as an additional check that only makes sense with 1.2
// generated files. Note that it is entirely possible that
// the M_PRIVATE bit is always enough. We are being
// conservative here.
//
// The ATT_ALLCLASSES flag causes the M_PRIVATE modifier
// to be ignored, and is used by tools such as 'javap' that
// wish to examine all classes regardless of the normal access
// controls that apply during compilation. Note that anonymous
// and local classes are still not considered accessible, though
// named local classes in jdk1.1 may slip through. Note that
// this accessibility test is an optimization, and it is safe to
// err on the side of greater accessibility.
boolean accessible =
// The reader should note that there has been a significant change
// in the way that the InnerClasses attribute is being handled.
// In particular, previously the compiler called initInner() for
// <em>every</em> inner class. Now the compiler does not call
// initInner() if the inner class is inaccessible. This means
// that inaccessible inner classes don't have any of the processing
// from initInner() done for them: fixing the access flags,
// setting outerClass, setting outerMember in their outerClass,
// etc. We believe this is fine: if the class is inaccessible
// and binary, then everyone who needs to see its internals
// has already been compiled. Hopefully.
if (accessible) {
Identifier nm =
// Tell the type module about the nesting relation:
// The inner class in the record is this class.
try {
} catch (ClassNotFound e) {
// report the error elsewhere
}
// The outer class in the record is this class.
try {
} catch (ClassNotFound e) {
// report the error elsewhere
}
}
}
}
}
if (getOuterClass() != null)
return; // already done
/******
// Maybe set static, protected, or private.
if ((modifiers & M_PUBLIC) != 0)
mods &= M_STATIC;
else
mods &= M_PRIVATE | M_PROTECTED | M_STATIC;
modifiers |= mods;
******/
// For an inner class, the class access may have been weakened
// from that originally declared the source. We must take the
// actual access permissions against which we check any source
// we are currently compiling from the InnerClasses attribute.
// We attempt to guard here against bogus combinations of modifiers.
// Private cannot be combined with public or protected.
// Protected cannot be combined with public.
}
// All interfaces are implicitly abstract.
// All interfaces that are members of a type are implicitly static.
}
if (outerClass.isInterface()) {
// All types that are members of interfaces are implicitly
// public and static.
}
if (field.isUplevelValue()
}
}
}
if (innerClass instanceof BinaryClass)
}
/**
* Write the class out to a given stream. This function mirrors the loader.
*/
// write out the header
// Write out the constant pool
// Write class information
}
// count the fields and the methods
// write out each the field count, and then each field
if (!f.isMethod()) {
}
}
// write out each method count, and then each method
if (f.isMethod()) {
}
}
// write out the class attributes
}
/**
* Get the dependencies
*/
return dependencies.elements();
}
/**
* Add a dependency
*/
}
}
/**
* Get the constant pool
*/
return cpool;
}
/**
* Get a class attribute
*/
}
}
return null;
}
}