/*
* 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.
*/
/**
* A Source Member
*
* 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
/**
* The argument names (if it is a method)
*/
// set to the MemberDefinition in the interface if we have this field because
// it has been forced on us
/**
* The status of the field
*/
int status;
return args;
}
/**
* Constructor
* @param argNames a vector of IdentifierToken
*/
this.documentation = doc;
// not until type names are resolved: createArgumentFields(argNames);
this.modifiers |= M_DEPRECATED;
}
}
// Create a list of arguments
if (isMethod()) {
}
Object x = e.nextElement();
if (x instanceof LocalMember) {
// This should not happen, but it does
// in cases of vicious cyclic inheritance.
return;
}
int mod;
long where;
if (x instanceof Identifier) {
// allow argNames to be simple Identifiers (deprecated!)
id = (Identifier)x;
mod = 0;
} else {
}
}
}
}
}
// The methods addOuterThis() and addUplevelArguments() were
// both originally part of a single method called addUplevelArguments()
// which took a single boolean parameter describing which of the
// two behaviors it wanted.
//
// The original addUplevelArguments() claimed to keep the arguments in
// the following order:
//
// (1) <this> <early outer this> <uplevel arguments...> <true arguments...>
//
// (By <early outer this> I am referring to the clientOuterField added
// to some constructors when they are created. If an outer this is
// added later, on demand, then this is mixed in with the rest of the
// uplevel arguments and is added by addUplevelArguments.)
//
// In reality, the `args' Vector was generated in this order, but the
// Type array `argTypes' was generated as:
//
// (2) <this> <uplevel arguments...> <early outer this> <true arguments...>
//
// This didn't make a difference in the common case -- that is, when
// a class had an <outer.this> or <uplevel arguments...> but not both.
// Both can happen in the case that a member class is declared inside
// of a local class. It seems that the calling sequences, generated
// in places like NewInstanceExpression.codeCommon(), use order (2),
// so I have changed the code below to stick with that order. Since
// the only time this happens is in classes which are insideLocal, no
// one should be able to tell the difference between these orders.
// (bug number 4085633)
/**
* Get outer instance link, or null if none.
*/
return outerThisArg;
}
/**
* Add the outer.this argument to the list of arguments for this
* constructor. This is called from resolveTypeStructure. Any
* additional uplevel arguments get added later by addUplevelArguments().
*/
void addOuterThis() {
// See if we have a client outer field.
!refs.isClientOuterField()) {
}
// There is no outer this argument. Quit.
return;
}
// Get the old arg types.
// And make an array for the new ones with space for one more.
outerThisArg = arg;
// args is our list of arguments. It contains a `this', so
// we insert at position 1. The list of types does not have a
// this, so we insert at position 0.
// Add on the rest of the constructor arguments.
}
}
/**
* Prepend argument names and argument types for local variable references.
* This information is never seen by the type-check phase,
* but it affects code generation, which is the earliest moment
* we have comprehensive information on uplevel references.
* The code() methods tweaks the constructor calls, prepending
* the proper values to the argument list.
*/
void addUplevelArguments() {
// Count how many uplevels we have to add.
int count = 0;
if (!r.isClientOuterField()) {
count += 1;
}
}
if (count == 0) {
// None to add, quit.
return;
}
// Get the old argument types.
// Make an array with enough room for the new.
// Add all of the late uplevel references to args and argTypes.
// Note that they are `off-by-one' because of the `this'.
int ins = 0;
if (!r.isClientOuterField()) {
ins++;
}
}
// Add the rest of the old arguments.
}
}
/**
* Constructor for an inner class.
*/
super(innerClass);
}
/**
* Constructor.
* Used only to generate an abstract copy of a method that a class
* inherits from an interface
*/
this(f.getWhere(), c, f.getDocumentation(),
f.getExceptionIds(), null);
this.args = f.getArguments();
this.abstractSource = f;
}
/**
* Get exceptions
*/
return exp;
}
// (should not happen)
return exp;
}
// be sure to get the imports right:
}
return exp;
}
/**
* Set array of name-resolved exceptions directly, e.g., for access methods.
*/
}
/**
* Resolve types in a field, after parsing.
* @see ClassDefinition.resolveTypeStructure
*/
public boolean resolved = false;
// A member should only be resolved once. For a constructor, it is imperative
// that 'addOuterThis' be called only once, else the outer instance argument may
// be inserted into the argument list multiple times.
if (resolved) {
// This case shouldn't be happening. It is the responsibility
// of our callers to avoid attempting multiple resolutions of a member.
// *** REMOVE FOR SHIPMENT? ***
throw new CompilerError("multiple member type resolution");
//return;
} else {
resolved = true;
}
super.resolveTypeStructure(env);
if (isInnerClass()) {
}
} else {
// Expand all class names in 'type', including those that are not
// fully-qualified or refer to inner classes, into fully-qualified
// names. Local and anonymous classes get synthesized names here,
// corresponding to the class files that will be generated. This is
// currently the only place where 'resolveNames' is used.
// do the throws also:
if (isMethod()) {
// Add outer instance argument for constructors.
if (isConstructor()) {
addOuterThis();
}
}
}
}
/**
* Get the class declaration in which the field is actually defined
*/
if (abstractSource == null)
return super.getDefiningClassDeclaration();
else
return abstractSource.getDefiningClassDeclaration();
}
/**
* A source field never reports deprecation, since the compiler
* allows access to deprecated features that are being compiled
* in the same job.
*/
return false;
}
/**
* Check this field.
* <p>
* This is the method which requests checking.
* The real work is done by
* <tt>Vset check(Environment, Context, Vset)</tt>.
*/
// rely on the class to check all fields in the proper order
// break a big cycle for small synthetic variables
if (tracing)
return;
}
if (getClassDefinition().getError()) {
} else {
if (tracing)
throw new CompilerError("check failed");
}
}
}
}
/**
* Check a field.
* @param vset tells which uplevel variables are definitely assigned
* The vset is also used to track the initialization of blank finals
* by whichever fields which are relevant to them.
*/
if (isInnerClass()) {
// some classes are checked separately
&& nc.isInsideLocal()) {
}
return vset;
}
}
}
// This is where all checking of names appearing within the type
// of the member is done. Includes return type and argument types.
// Since only one location ('where') for error messages is provided,
// localization of errors is poor. Throws clauses are handled below.
// Make sure that all the classes that we claim to throw really
// are subclasses of Throwable, and are classes that we can reach
if (isMethod()) {
}
try {
// Validate access for all inner-class components
// of a qualified name, not just the last one, which
// is checked below. Yes, this is a dirty hack...
// Part of fix for 4094658.
} catch (ClassNotFound e) {
break;
}
if (!getClassDefinition().
}
}
}
for (int i = 0; i < length; i++) {
for (int j = i + 1; j < length; j++) {
name_i);
break outer_loop;
}
}
}
}
if (isMethod()) {
// initialize vset, indication that each of the arguments
// to the function has a value
}
if (isConstructor()) {
// Undefine "this" in some constructors, until after
// the super constructor has been called.
// If the first thing in the definition isn't a call
// to either super() or this(), then insert one.
supCall);
setValue(s);
}
}
//System.out.println("VSET = " + vset);
continue;
}
boolean ok = false;
if (!isInitializer()) {
ok = true;
}
}
}
if (!ok) {
if (isConstructor()) {
if (where ==
getClassDefinition().getWhere()) {
// If this message is being generated for
// a default constructor, we should give
// a different error message. Currently
// we check for this by seeing if the
// constructor has the same "where" as
// its class. This is a bit kludgy, but
// works. (bug id 4034836)
errorMsg = "def.constructor.exception";
} else {
// Constructor with uncaught exception.
errorMsg = "constructor.exception";
}
} else if (isInitializer()) {
// Initializer with uncaught exception.
errorMsg = "initializer.exception";
} else {
// Method with uncaught exception.
errorMsg = "uncaught.exception";
}
}
}
} else {
// Complain about static final members of inner classes that
// do not have an initializer that is a constant expression.
// In general, static members are not permitted for inner
// classes, but an exception is made for named constants.
// Other cases of static members, including non-final ones,
// are handled in 'SourceClass'. Part of fix for 4095568.
}
}
// Both RuntimeExceptions and Errors should be
// allowed in initializers. Fix for bug 4102541.
"initializer.exception", c.getName());
}
}
}
}
}
}
// Initializers (static and instance) must be able to complete normally.
}
return vset;
}
// helper to check(): synthesize a missing super() call
// does the superclass constructor require an enclosing instance?
: sclass.getOuterClass();
}
}
}
/**
* Inline the field
*/
switch (status) {
case PARSED:
break;
case CHECKED:
}
if (isMethod()) {
if ((!isNative()) && (!isAbstract())) {
}
}
} else if (isInnerClass()) {
// some classes are checked and inlined separately
&& nc.isInsideLocal()) {
}
break;
} else {
if (!isStatic()) {
// Cf. "thisArg" in SourceClass.checkMembers().
} else {
}
}
}
} else {
}
}
break;
}
}
/**
* Get the value of the field (or null if the value can't be determined)
*/
// be sure to get the imports right:
}
return value;
}
}
return false;
}
/**
* Get the initial value of the field
*/
return null;
}
}
/**
* Generate code
*/
switch (status) {
case PARSED:
return;
case CHECKED:
return;
case INLINED:
// Actually generate code
}
//ctx.declare(env, (LocalMember)e.nextElement());
}
/*
if (isConstructor() && ((s == null) || (s.firstConstructor() == null))) {
ClassDeclaration c = getClassDefinition().getSuperClass();
if (c != null) {
MemberDefinition field = c.getClassDefinition(env).matchMethod(env, getClassDefinition(), idInit);
asm.add(getWhere(), opc_aload, new Integer(0));
asm.add(getWhere(), opc_invokespecial, field);
asm.add(getWhere(), opc_pop);
}
// Output initialization code
for (MemberDefinition f = getClassDefinition().getFirstMember() ; f != null ; f = f.getNextMember()) {
if (!f.isStatic()) {
f.codeInit(env, ctx, asm);
}
}
}
*/
if (s != null) {
}
}
}
return;
}
}
if (isMethod()) {
return;
}
switch (status) {
case PARSED:
return;
case CHECKED:
return;
case INLINED:
// Actually generate code
}
// The JLS Section 8.5 specifies that static (non-final)
// initializers should be executed in textual order. Eliding
// initializations to default values can interfere with this,
// so the tests for !e.equalsDefault() have been eliminated,
// below.
if (isStatic()) {
if (getInitialValue() == null) {
// removed: && !e.equalsDefault()) {
}
} else { // removed: if (!e.equalsDefault()) {
// This code doesn't appear to be reached for
// instance initializers. Code for these is generated
// in the makeVarInits() method of the class
// MethodExpression.
}
}
return;
}
}
/**
* Print for debugging
*/
}
}
}