src/share/classes/com/sun/tools/javac/comp/AttrContext.java

Thu, 21 Feb 2013 15:19:29 +0000

author
mcimadamore
date
Thu, 21 Feb 2013 15:19:29 +0000
changeset 1595
d686d8a7eb78
parent 1409
33abf479f202
child 2390
b06c2db45ddb
permissions
-rw-r--r--

8008227: Mixing lambdas with anonymous classes leads to NPE thrown by compiler
Summary: Disentangle cyclic dependency between static-ness of synthetic lambda method and static-ness of classes nested within lambdas
Reviewed-by: jjg

duke@1 1 /*
jjh@1305 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
duke@1 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
duke@1 10 *
duke@1 11 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 14 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 15 * accompanied this code).
duke@1 16 *
duke@1 17 * You should have received a copy of the GNU General Public License version
duke@1 18 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
duke@1 24 */
duke@1 25
duke@1 26 package com.sun.tools.javac.comp;
duke@1 27
duke@1 28 import com.sun.tools.javac.util.*;
duke@1 29 import com.sun.tools.javac.code.*;
duke@1 30
duke@1 31 /** Contains information specific to the attribute and enter
duke@1 32 * passes, to be used in place of the generic field in environments.
duke@1 33 *
jjg@581 34 * <p><b>This is NOT part of any supported API.
jjg@581 35 * If you write code that depends on this, you do so at your own risk.
duke@1 36 * This code and its internal interfaces are subject to change or
duke@1 37 * deletion without notice.</b>
duke@1 38 */
duke@1 39 public class AttrContext {
duke@1 40
duke@1 41 /** The scope of local symbols.
duke@1 42 */
duke@1 43 Scope scope = null;
duke@1 44
duke@1 45 /** The number of enclosing `static' modifiers.
duke@1 46 */
duke@1 47 int staticLevel = 0;
duke@1 48
duke@1 49 /** Is this an environment for a this(...) or super(...) call?
duke@1 50 */
duke@1 51 boolean isSelfCall = false;
duke@1 52
duke@1 53 /** Are we evaluating the selector of a `super' or type name?
duke@1 54 */
duke@1 55 boolean selectSuper = false;
duke@1 56
duke@1 57 /** Are arguments to current function applications boxed into an array for varargs?
duke@1 58 */
mcimadamore@1347 59 Resolve.MethodResolutionPhase pendingResolutionPhase = null;
duke@1 60
duke@1 61 /** A record of the lint/SuppressWarnings currently in effect
duke@1 62 */
duke@1 63 Lint lint;
duke@1 64
mcimadamore@94 65 /** The variable whose initializer is being attributed
mcimadamore@94 66 * useful for detecting self-references in variable initializers
mcimadamore@94 67 */
mcimadamore@94 68 Symbol enclVar = null;
mcimadamore@94 69
mcimadamore@1347 70 /** ResultInfo to be used for attributing 'return' statement expressions
mcimadamore@1347 71 * (set by Attr.visitMethod and Attr.visitLambda)
mcimadamore@1347 72 */
mcimadamore@1347 73 Attr.ResultInfo returnResult = null;
mcimadamore@1347 74
mcimadamore@1393 75 /** Symbol corresponding to the site of a qualified default super call
mcimadamore@1393 76 */
mcimadamore@1393 77 Type defaultSuperCallSite = null;
mcimadamore@1393 78
duke@1 79 /** Duplicate this context, replacing scope field and copying all others.
duke@1 80 */
duke@1 81 AttrContext dup(Scope scope) {
duke@1 82 AttrContext info = new AttrContext();
duke@1 83 info.scope = scope;
duke@1 84 info.staticLevel = staticLevel;
duke@1 85 info.isSelfCall = isSelfCall;
duke@1 86 info.selectSuper = selectSuper;
mcimadamore@1347 87 info.pendingResolutionPhase = pendingResolutionPhase;
duke@1 88 info.lint = lint;
mcimadamore@94 89 info.enclVar = enclVar;
mcimadamore@1347 90 info.returnResult = returnResult;
mcimadamore@1393 91 info.defaultSuperCallSite = defaultSuperCallSite;
duke@1 92 return info;
duke@1 93 }
duke@1 94
duke@1 95 /** Duplicate this context, copying all fields.
duke@1 96 */
duke@1 97 AttrContext dup() {
duke@1 98 return dup(scope);
duke@1 99 }
duke@1 100
duke@1 101 public Iterable<Symbol> getLocalElements() {
duke@1 102 if (scope == null)
duke@1 103 return List.nil();
duke@1 104 return scope.getElements();
duke@1 105 }
duke@1 106
mcimadamore@1347 107 boolean lastResolveVarargs() {
mcimadamore@1347 108 return pendingResolutionPhase != null &&
mcimadamore@1347 109 pendingResolutionPhase.isVarargsRequired();
mcimadamore@1347 110 }
mcimadamore@1347 111
jjg@1409 112 @Override
duke@1 113 public String toString() {
duke@1 114 return "AttrContext[" + scope.toString() + "]";
duke@1 115 }
duke@1 116 }

mercurial