/*
* 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
/**
* constructor
*/
}
}
// This is a hack used only within certain access methods generated by
// 'SourceClass.getAccessMember'. It allows an 'invokespecial' instruction
// to be forced even though 'super' does not appear within the call.
// Such access methods are needed for access to protected methods when using
// the qualified '<class>.super.<method>(...)' notation.
this.isSuper = forceSuper;
}
if (implementation != null)
return implementation;
return this;
}
/**
* Check expression type
*/
ClassDeclaration c = null;
boolean isArray = false;
boolean staticRef = false;
// Access method to use if required.
// When calling a constructor, we may need to add an
// additional argument to transmit the outer instance link.
try {
if (right instanceof SuperExpression) {
// outer.super(...)
} else if (right instanceof ThisExpression) {
// outer.this(...)
}
} catch (ClassNotFound ee) {
// the same error is handled elsewhere
}
}
// The effective accessing class, for access checking.
// This is normally the immediately enclosing class.
try {
// Find the first outer scope that mentions the method.
MemberDefinition m = null;
if (m != null) {
break;
}
}
if (m == null) {
// this is the scope for error diagnosis
} else {
// found the innermost scope in which m occurs
c = cdef.getClassDeclaration();
// Maybe an inherited method hides an apparent method.
// Keep looking at enclosing scopes to find out.
if (m.getClassDefinition() != cdef) {
break;
}
}
}
}
} else {
}
// forthcoming 2e), all variables are both definitely assigned
// and definitely unassigned in unreachable code. Normally, this
// correctly suppresses DA/DU-related errors in such code.
// The use of the DA status of the 'this' variable for the extra
// check below on correct constructor usage, however, does not quite
// Vsets for unreachable dead-ends, does not allow 'clearVar'
// of the 'this' variable is supposed to be temporarily
// cleared at the beginning of a constructor and during the
// checking of constructor arguments (see below in this method).
// Since 'clearVar' has no effect on dead-ends, we may
// find the 'this' variable in an erroneously definitely-assigned state.
// As a workaround, we suppress the following error message when
// the Vset is a dead-end, i.e., when we are in unreachable code.
// Unfortunately, the special-case treatment of reachability for
// if-then and if-then-else allows unreachable code in some circumstances,
// thus it is possible that no error message will be emitted at all.
// While this behavior is strictly incorrect (thus we call this a
// workaround), the problematic code is indeed unreachable and will
// not be executed. In fact, it will be entirely omitted from the
// translated program, and can cause no harm at runtime. A correct
// analysis to use finite Vsets only, restricting the universe
// of variables about which assertions are made (even in unreachable
// code) to variables that are actually in scope. Alternatively, the
// Vset extension and the dead-end marker (currently a reserved value
// of the extension) could be represented orthogonally. In either case,
// 'clearVar' could then be made to work on (non-canonical) dead ends.
// See file 'Vset.java'.
return vset;
}
if (right instanceof SuperExpression) {
// supers require this specific kind of checking
} else {
}
} else {
return vset;
}
if (right instanceof TypeExpression) {
staticRef = true;
}
}
isArray = true;
} else {
}
return vset;
}
// Normally, the effective accessing class is the innermost
// class surrounding the current method call, but, for calls
// of the form '<class>.super.<method>(...)', it is <class>.
// This allows access to protected members of a superclass
// from within a class nested within one of its subclasses.
// Otherwise, for example, the call below to 'matchMethod'
// may fail due to the rules for visibility of inaccessible
// members. For consistency, we treat qualified 'this' in
// the same manner, as error diagnostics will be affected.
// QUERY: Are there subtle unexplored language issues here?
if (right instanceof FieldExpression) {
isSuper = true;
}
} else if (right instanceof SuperExpression) {
isSuper = true;
}
// Fix for 4158650. When we extend a protected inner
// class in a different package, we may not have access
// to the type of our superclass. Allow the call to
// the superclass constructor from within our constructor
// Note that this check does not apply to constructor
// calls in new instance expressions -- those are part
// of NewInstanceExpression#check().
// Required by JLS 6.6.1. Fixes 4143715.
// (See also 4094658.)
sourceClass)) {
if (staticRef) {
} else {
}
}
}
}
// Compose a list of argument types
boolean hasErrors = false;
// "this" is not defined during argument checking
}
}
// "this" is defined after the constructor invocation
}
// Check if there are any type errors in the arguments
if (hasErrors) {
return vset;
}
// Get the method field, given the argument types
return vset;
return vset;
}
} else {
}
} else {
}
return vset;
}
}
// Make sure that static references are allowed
return vset;
}
if (field.isProtected()
&& !(right instanceof SuperExpression
// Extension of JLS 6.6.2 for qualified 'super'.
|| (right instanceof FieldExpression &&
return vset;
}
// In <class>.super.<method>(), we cannot simply evaluate
// <class>.super to an object reference (as we would for
// <class>.super.<field>) and then perform an 'invokespecial'.
// An 'invokespecial' must be performed from within (a subclass of)
// the class in which the target method is located.
if (right instanceof FieldExpression &&
// The private case is handled below.
// Use an access method unless the effective accessing class
// (the class qualifying the 'super') is the same as the
// immediately enclosing class, i.e., the qualification was
// unnecessary.
if (sourceClass != ctxClass) {
}
}
}
// Access method for private field if not in the same class.
}
}
// Make sure that we are not invoking an abstract method
return vset;
}
if (field.isConstructor()) {
} else {
}
}
// Check for recursive constructor
}
// When a package-private class defines public or protected
// members, those members may sometimes be accessed from
// outside of the package in public subclasses. In these
// cases, we need to massage the method call to refer to
// to an accessible subclass rather than the package-private
// parent class. Part of fix for 4135692.
// Find out if the class which contains this method
// call has access to the class which declares the
// public or protected method referent.
// We don't perform this translation on constructor calls.
if (sourceClass == ctxClass) {
if (!field.isConstructor() &&
declarer.isPackagePrivate() &&
//System.out.println("The access of member " +
// field + " declared in class " +
// declarer +
// " is not allowed by the VM from class " +
// accessor +
// ". Replacing with an access of class " +
// clazz);
// We cannot make this access at the VM level.
// Construct a member which will stand for this
// method in clazz and set `field' to refer to it.
field =
}
}
if (sourceClass != ctxClass) {
}
} catch (ClassNotFound ee) {
return vset;
} catch (AmbiguousMember ee) {
return vset;
}
// Make sure it is qualified
}
// Cast arguments
}
if (field.isConstructor()) {
MemberDefinition m = field;
if (implMethod != null) {
m = implMethod;
}
// Argument was added above.
// Maintain the model for hidden outer args in outer.super(...):
if (right instanceof SuperExpression) {
} else if (right instanceof ThisExpression) {
} else {
throw new CompilerError("this.init");
}
if (implMethod != null) {
// Need dummy argument for access method.
// Dummy argument follows outer instance link.
// Leave 'this.args' equal to 'newargs' but
// without the outer instance link.
for (int i = 1 ; i < nargs ; i++) {
}
} else {
// Strip outer instance link from 'this.args'.
// ASSERT(this.arg.length == nargs-1);
for (int i = 1 ; i < nargs ; i++) {
}
}
} else {
// No argument was added.
if (implMethod != null) {
// Need dummy argument for access method.
// Dummy argument is first, as there is no outer instance link.
for (int i = 0 ; i < nargs ; i++) {
}
}
}
} else {
// Have ordinary method.
// Argument should have been added only for a constructor.
throw new CompilerError("method arg");
}
if (implMethod != null) {
//System.out.println("Calling " + field + " via " + implMethod);
} else {
// Access method needs an explicit 'this' pointer.
for (int i = 0; i < nargs; i++) {
}
}
}
}
// Follow super() by variable initializations
if (e != null) {
if (implementation == null)
}
}
// Throw the declared exceptions.
/* Arrays pretend that they have "public Object clone()" that doesn't
* throw anything, according to the language spec.
*/
/* See if there's a bogus catch for it, to issue a warning. */
}
}
}
}
}
// Mark all blank finals as definitely assigned following 'this(...)'.
// Correctness follows inductively from the requirement that all blank finals
// be definitely assigned at the completion of every constructor.
// Static variables should also be considered defined as well, but this
// is handled in 'SourceClass.checkMembers', and we should not interfere.
}
}
}
return vset;
}
/**
* Check void expression
*/
}
/**
* We're about to report a "unmatched method" error.
* Try to issue a better diagnostic by comparing the actual argument types
* with the method (or methods) available.
* In particular, if there is an argument which fails to match <em>any</em>
* method, we report a type mismatch error against that particular argument.
* The diagnostic will report a target type taken from one of the methods.
* <p>
* Return false if we couldn't think of anything smart to say.
*/
boolean saidSomething = false;
int start = 0;
if (code == -2) {
saidSomething = true;
}
if (code < 0) break;
int i = code >> 2;
// At least one argument is offensive to all overloadings.
// targetType is one of the argument types it does not match.
// The message might be slightly misleading, if there are other
// argument types that also would match. Hint at this:
//if (ambig) ttype = "{"+ttype+";...}";
if (castOK)
else
saidSomething = true;
}
return saidSomething;
}
/**
* Inline
*/
private
}
int n = 0;
} else {
}
}
}
//System.out.print("BEFORE:"); s.print(System.out); System.out.println();
// Note: If !valNeeded, then all returns in the body of the method
// change to void returns.
//System.out.print("COPY:"); body[body.length - 1].print(System.out); System.out.println();
// Make sure the type matches what the return statements are returning.
}
if (implementation != null)
try {
}
}
// ctxClass is the current class trying to inline this method
Expression e = this;
// Don't inline if a qualified non-static method: the call
// itself might throw NullPointerException as a side effect
// We only allow the inlining if the current class can access
// the field, the field's class, and right's declared type.
field.getClassDeclaration()) &&
if ((s == null) ||
}
}
return e;
} catch (ClassNotFound e) {
throw new CompilerError(e);
}
}
if (implementation != null)
try {
}
if (r != null) {
}
}
}
// ctxClass is the current class trying to inline this method
// Don't inline if a qualified non-static method: the call
// itself might throw NullPointerException as a side effect
// We only allow the inlining if the current class can access
// the field, the field's class, and right's declared type.
field.getClassDeclaration()) &&
if ((s == null) ||
}
}
return this;
} catch (ClassNotFound e) {
throw new CompilerError(e);
}
}
if (implementation != null)
return super.copyInline(ctx);
}
if (implementation != null)
// for now, don't allow calls to super() to be inlined. We may fix
// this later
return thresh;
}
}
/*
* Grab all instance initializer code from the class definition,
* and return as one bolus. Note that we are assuming the
* the relevant fields have already been checked.
* (See the pre-pass in SourceClass.checkMembers which ensures this.)
*/
// insert instance initializers
Expression e = null;
try {
} catch (ClassNotFound ee) {
f.getClassDefinition());
}
if (f.isUplevelValue()) {
if (f != clazz.findOuterMember()) {
// it's too early to accumulate these
continue;
}
}
} else if (f.isInitializer()) {
} else {
}
// append all initializers to "e":
// This section used to check for variables which were
// initialized to their default values and elide such
// initialization. This is specifically disallowed by
// JLS 12.5 numeral 4, which requires a textual ordering
// on the execution of initializers.
long p = f.getWhere();
if (f.isVariable()) {
v = new FieldExpression(p, v, f);
}
}
}
}
return e;
}
/**
* Code
*/
if (implementation != null)
throw new CompilerError("codeValue");
int i = 0; // argument index
}
// 'super.<method>(...)', 'super(...)', or '<expr>.super(...)'
/*****
isSuper = true;
*****/
// 'super(...)' or '<expr>.super(...)' only
if (r != null) {
// When calling a constructor for a class with
// embedded uplevel references, add extra arguments.
if (r.isClientOuterField()) {
// the extra arguments are inserted after this one
}
}
}
} else {
/*****
if (right.op == FIELD &&
((FieldExpression)right).id == idSuper) {
// '<class>.super.<method>(...)'
isSuper = true;
}
*****/
}
}
} else {
}
// 'super(...)' or '<expr>.super(...)'
if (r != null) {
// After calling a superclass constructor in a class with
// embedded uplevel references, initialize uplevel fields.
}
}
}
/**
* Check if the first thing is a constructor invocation
*/
}
/**
* Print
*/
}
} else {
}
}
if (implementation != null) {
}
}
}