aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/com/sun
diff options
context:
space:
mode:
Diffstat (limited to 'src/share/classes/com/sun')
-rw-r--r--src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java4
-rw-r--r--src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java24
-rw-r--r--src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties2
-rw-r--r--src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties7
-rw-r--r--src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties7
-rw-r--r--src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties7
-rw-r--r--src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css2
-rw-r--r--src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java26
-rw-r--r--src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java4
-rw-r--r--src/share/classes/com/sun/tools/javac/code/Scope.java14
-rw-r--r--src/share/classes/com/sun/tools/javac/code/Symbol.java10
-rw-r--r--src/share/classes/com/sun/tools/javac/code/Type.java18
-rw-r--r--src/share/classes/com/sun/tools/javac/code/Types.java232
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/Attr.java97
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/AttrContext.java9
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/Check.java71
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java37
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/Flow.java658
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/Infer.java10
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java54
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/Lower.java2
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/Resolve.java69
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/TransTypes.java2
-rw-r--r--src/share/classes/com/sun/tools/javac/jvm/ClassReader.java22
-rw-r--r--src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java5
-rw-r--r--src/share/classes/com/sun/tools/javac/jvm/Code.java43
-rw-r--r--src/share/classes/com/sun/tools/javac/jvm/Gen.java391
-rw-r--r--src/share/classes/com/sun/tools/javac/jvm/LVTRanges.java129
-rw-r--r--src/share/classes/com/sun/tools/javac/parser/JavacParser.java24
-rw-r--r--src/share/classes/com/sun/tools/javac/resources/javac.properties6
-rw-r--r--src/share/classes/com/sun/tools/javac/resources/javac_ja.properties4
-rw-r--r--src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties4
-rw-r--r--src/share/classes/com/sun/tools/javac/tree/TreeInfo.java13
-rw-r--r--src/share/classes/com/sun/tools/javac/util/Bits.java16
-rw-r--r--src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java21
-rw-r--r--src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java17
-rw-r--r--src/share/classes/com/sun/tools/javadoc/TypeMaker.java16
-rw-r--r--src/share/classes/com/sun/tools/jdeps/Analyzer.java2
-rw-r--r--src/share/classes/com/sun/tools/jdeps/JdepsTask.java48
-rw-r--r--src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java16
40 files changed, 873 insertions, 1270 deletions
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
index f634638b..dbd857dd 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
@@ -113,7 +113,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
Content captionSpan;
Content span;
if (type.isDefaultTab()) {
- captionSpan = HtmlTree.SPAN(new StringContent(type.text()));
+ captionSpan = HtmlTree.SPAN(configuration.getResource(type.resourceKey()));
span = HtmlTree.SPAN(type.tabId(),
HtmlStyle.activeTableTab, captionSpan);
} else {
@@ -136,7 +136,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
*/
public Content getMethodTypeLinks(MethodTypes methodType) {
String jsShow = "javascript:show(" + methodType.value() +");";
- HtmlTree link = HtmlTree.A(jsShow, new StringContent(methodType.text()));
+ HtmlTree link = HtmlTree.A(jsShow, configuration.getResource(methodType.resourceKey()));
return link;
}
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
index f74c0849..ae748c3b 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
@@ -471,10 +471,10 @@ public class HtmlWriter {
for (Map.Entry<String,Integer> entry : typeMap.entrySet()) {
vars.append(sep);
sep = ",";
- vars.append("\"");
- vars.append(entry.getKey());
- vars.append("\":");
- vars.append(entry.getValue());
+ vars.append("\"")
+ .append(entry.getKey())
+ .append("\":")
+ .append(entry.getValue());
}
vars.append("};").append(DocletConstants.NL);
sep = "";
@@ -482,11 +482,19 @@ public class HtmlWriter {
for (MethodTypes entry : methodTypes) {
vars.append(sep);
sep = ",";
- vars.append(entry.value()).append(":");
- vars.append("[").append("\"").append(entry.tabId());
- vars.append("\"").append(sep).append("\"").append(entry.text()).append("\"]");
+ vars.append(entry.value())
+ .append(":")
+ .append("[")
+ .append("\"")
+ .append(entry.tabId())
+ .append("\"")
+ .append(sep)
+ .append("\"")
+ .append(configuration.getText(entry.resourceKey()))
+ .append("\"]");
}
- vars.append("};").append(DocletConstants.NL);
+ vars.append("};")
+ .append(DocletConstants.NL);
addStyles(HtmlStyle.altColor, vars);
addStyles(HtmlStyle.rowColor, vars);
addStyles(HtmlStyle.tableTab, vars);
diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties
index bd7ea237..273fa87c 100644
--- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties
@@ -190,4 +190,4 @@ doclet.usage=\u6A19\u6E96\u306Edoclet\u306B\u3088\u308A\u63D0\u4F9B\u3055\u308C\
# L10N: do not localize these words: all none accessibility html missing reference syntax
-doclet.X.usage=\u6A19\u6E96\u306Edoclet\u306B\u3088\u308A\u63D0\u4F9B\u3055\u308C\u308B\u3082\u306E:\n -Xdocrootparent <url> doc\u30B3\u30E1\u30F3\u30C8\u5185\u306E/..\u304C\u5F8C\u306B\u7D9A\u304F@docRoot\u306E\u3059\u3079\u3066\u3092\n <url>\u3067\u7F6E\u63DB\u3057\u307E\u3059\n -Xdoclint javadoc\u30B3\u30E1\u30F3\u30C8\u5185\u306E\u554F\u984C\u306B\u5BFE\u3059\u308B\u63A8\u5968\u3055\u308C\u308B\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u306B\u3057\u307E\u3059\n -Xdoclint:(all|none|[-]<group>) \n javadoc\u30B3\u30E1\u30F3\u30C8\u5185\u306E\u554F\u984C\u306B\u5BFE\u3059\u308B\u7279\u5B9A\u306E\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u307E\u305F\u306F\u7121\u52B9\u306B\u3057\u307E\u3059\u3002\n \u3053\u3053\u3067\u3001<group>\u306Fhtml\u3001missing\u3001reference\u307E\u305F\u306Fsyntax\u306E\u3044\u305A\u308C\u304B\u3067\u3059\u3002\n
+doclet.X.usage=\u6A19\u6E96\u306Edoclet\u306B\u3088\u308A\u63D0\u4F9B\u3055\u308C\u308B\u3082\u306E:\n -Xdocrootparent <url> doc\u30B3\u30E1\u30F3\u30C8\u5185\u306E/..\u304C\u5F8C\u306B\u7D9A\u304F@docRoot\u306E\u3059\u3079\u3066\u3092\n <url>\u3067\u7F6E\u63DB\u3057\u307E\u3059\n -Xdoclint javadoc\u30B3\u30E1\u30F3\u30C8\u5185\u306E\u554F\u984C\u306B\u5BFE\u3059\u308B\u63A8\u5968\u3055\u308C\u308B\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u306B\u3057\u307E\u3059\n -Xdoclint:(all|none|[-]<group>) \n javadoc\u30B3\u30E1\u30F3\u30C8\u5185\u306E\u554F\u984C\u306B\u5BFE\u3059\u308B\u7279\u5B9A\u306E\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u307E\u305F\u306F\u7121\u52B9\u306B\u3057\u307E\u3059\u3002\n \u3053\u3053\u3067\u3001<group>\u306Faccessibility\u3001html\u3001missing\u3001reference\u307E\u305F\u306Fsyntax\u306E\u3044\u305A\u308C\u304B\u3067\u3059\u3002\n
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
index cf21120f..597dd35e 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
@@ -150,6 +150,13 @@ doclet.constructors=constructors
doclet.Constructors=Constructors
doclet.methods=methods
doclet.Methods=Methods
+doclet.All_Methods=All Methods
+doclet.Static_Methods=Static Methods
+doclet.Instance_Methods=Instance Methods
+doclet.Abstract_Methods=Abstract Methods
+doclet.Concrete_Methods=Concrete Methods
+doclet.Default_Methods=Default Methods
+doclet.Deprecated_Methods=Deprecated Methods
doclet.annotation_type_optional_members=optional elements
doclet.Annotation_Type_Optional_Members=Optional Elements
doclet.annotation_type_required_members=required elements
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties
index 8b724b4f..8051a49b 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties
@@ -148,6 +148,13 @@ doclet.constructors=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF
doclet.Constructors=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF
doclet.methods=\u30E1\u30BD\u30C3\u30C9
doclet.Methods=\u30E1\u30BD\u30C3\u30C9
+doclet.All_Methods=\u3059\u3079\u3066\u306E\u30E1\u30BD\u30C3\u30C9
+doclet.Static_Methods=static\u30E1\u30BD\u30C3\u30C9
+doclet.Instance_Methods=\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9
+doclet.Abstract_Methods=abstract\u30E1\u30BD\u30C3\u30C9
+doclet.Concrete_Methods=concrete\u30E1\u30BD\u30C3\u30C9
+doclet.Default_Methods=\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9
+doclet.Deprecated_Methods=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30E1\u30BD\u30C3\u30C9
doclet.annotation_type_optional_members=\u4EFB\u610F\u8981\u7D20
doclet.Annotation_Type_Optional_Members=\u4EFB\u610F\u8981\u7D20
doclet.annotation_type_required_members=\u5FC5\u9808\u8981\u7D20
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties
index 28e4f54f..d67b2483 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties
@@ -148,6 +148,13 @@ doclet.constructors=\u6784\u9020\u5668
doclet.Constructors=\u6784\u9020\u5668
doclet.methods=\u65B9\u6CD5
doclet.Methods=\u65B9\u6CD5
+doclet.All_Methods=\u6240\u6709\u65B9\u6CD5
+doclet.Static_Methods=\u9759\u6001\u65B9\u6CD5
+doclet.Instance_Methods=\u5B9E\u4F8B\u65B9\u6CD5
+doclet.Abstract_Methods=\u62BD\u8C61\u65B9\u6CD5
+doclet.Concrete_Methods=\u5177\u4F53\u65B9\u6CD5
+doclet.Default_Methods=\u9ED8\u8BA4\u65B9\u6CD5
+doclet.Deprecated_Methods=\u5DF2\u8FC7\u65F6\u7684\u65B9\u6CD5
doclet.annotation_type_optional_members=\u53EF\u9009\u5143\u7D20
doclet.Annotation_Type_Optional_Members=\u53EF\u9009\u5143\u7D20
doclet.annotation_type_required_members=\u5FC5\u9700\u7684\u5143\u7D20
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
index cebb4fd8..98055b22 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
@@ -463,7 +463,6 @@ Table styles
.useSummary td, .constantsSummary td, .deprecatedSummary td {
text-align:left;
padding:0px 0px 12px 10px;
- width:100%;
}
th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th,
td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{
@@ -488,6 +487,7 @@ td.colOne, th.colOne {
font-size:13px;
}
.overviewSummary td.colFirst, .overviewSummary th.colFirst,
+.useSummary td.colFirst, .useSummary th.colFirst,
.overviewSummary td.colOne, .overviewSummary th.colOne,
.memberSummary td.colFirst, .memberSummary th.colFirst,
.memberSummary td.colOne, .memberSummary th.colOne,
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java
index 7b31ad81..24254350 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodTypes.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,22 +31,22 @@ package com.sun.tools.doclets.internal.toolkit.util;
* @author Bhavesh Patel
*/
public enum MethodTypes {
- ALL(0xffff, "All Methods", "t0", true),
- STATIC(0x1, "Static Methods", "t1", false),
- INSTANCE(0x2, "Instance Methods", "t2", false),
- ABSTRACT(0x4, "Abstract Methods", "t3", false),
- CONCRETE(0x8, "Concrete Methods", "t4", false),
- DEFAULT(0x10, "Default Methods", "t5", false),
- DEPRECATED(0x20, "Deprecated Methods", "t6", false);
+ ALL(0xffff, "doclet.All_Methods", "t0", true),
+ STATIC(0x1, "doclet.Static_Methods", "t1", false),
+ INSTANCE(0x2, "doclet.Instance_Methods", "t2", false),
+ ABSTRACT(0x4, "doclet.Abstract_Methods", "t3", false),
+ CONCRETE(0x8, "doclet.Concrete_Methods", "t4", false),
+ DEFAULT(0x10, "doclet.Default_Methods", "t5", false),
+ DEPRECATED(0x20, "doclet.Deprecated_Methods", "t6", false);
private final int value;
- private final String text;
+ private final String resourceKey;
private final String tabId;
private final boolean isDefaultTab;
- MethodTypes(int v, String t, String id, boolean dt) {
+ MethodTypes(int v, String k, String id, boolean dt) {
this.value = v;
- this.text = t;
+ this.resourceKey = k;
this.tabId = id;
this.isDefaultTab = dt;
}
@@ -55,8 +55,8 @@ public enum MethodTypes {
return value;
}
- public String text() {
- return text;
+ public String resourceKey() {
+ return resourceKey;
}
public String tabId() {
diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java
index 72cc196d..bc38491b 100644
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -250,7 +250,7 @@ public class VisibleMemberMap {
for (int i = 0; i < list.size(); i++) {
Object key = getMemberKey(list.get(i));
Map<ProgramElementDoc, String> memberLevelMap = memberNameMap.get(key);
- if (level.equals(memberLevelMap.get(list.get(i))))
+ if (memberLevelMap != null && level.equals(memberLevelMap.get(list.get(i))))
memberLevelMap.remove(list.get(i));
}
}
diff --git a/src/share/classes/com/sun/tools/javac/code/Scope.java b/src/share/classes/com/sun/tools/javac/code/Scope.java
index dee7c42f..b4899b2a 100644
--- a/src/share/classes/com/sun/tools/javac/code/Scope.java
+++ b/src/share/classes/com/sun/tools/javac/code/Scope.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -241,12 +241,16 @@ public class Scope {
listeners = listeners.prepend(sl);
}
- /** Remove symbol from this scope. Used when an inner class
- * attribute tells us that the class isn't a package member.
+ /** Remove symbol from this scope.
*/
- public void remove(Symbol sym) {
+ public void remove(final Symbol sym) {
Assert.check(shared == 0);
- Entry e = lookup(sym.name);
+ Entry e = lookup(sym.name, new Filter<Symbol>() {
+ @Override
+ public boolean accepts(Symbol candidate) {
+ return candidate == sym;
+ }
+ });
if (e.scope == null) return;
// remove e from table and shadowed list;
diff --git a/src/share/classes/com/sun/tools/javac/code/Symbol.java b/src/share/classes/com/sun/tools/javac/code/Symbol.java
index 9efd9f7b..f84ff831 100644
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java
+++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java
@@ -1153,6 +1153,16 @@ public abstract class Symbol extends AnnoConstruct implements Element {
public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
return v.visitClassSymbol(this, p);
}
+
+ public void markAbstractIfNeeded(Types types) {
+ if (types.enter.getEnv(this) != null &&
+ (flags() & ENUM) != 0 && types.supertype(type).tsym == types.syms.enumSym &&
+ (flags() & (FINAL | ABSTRACT)) == 0) {
+ if (types.firstUnimplementedAbstract(this) != null)
+ // add the ABSTRACT flag to an enum
+ flags_field |= ABSTRACT;
+ }
+ }
}
diff --git a/src/share/classes/com/sun/tools/javac/code/Type.java b/src/share/classes/com/sun/tools/javac/code/Type.java
index 017b85d2..2544199e 100644
--- a/src/share/classes/com/sun/tools/javac/code/Type.java
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java
@@ -421,6 +421,14 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
&& (tsym.flags() & COMPOUND) != 0;
}
+ public boolean isIntersection() {
+ return false;
+ }
+
+ public boolean isUnion() {
+ return false;
+ }
+
public boolean isInterface() {
return (tsym.flags() & INTERFACE) != 0;
}
@@ -970,6 +978,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
}
@Override
+ public boolean isUnion() {
+ return true;
+ }
+
+ @Override
public TypeKind getKind() {
return TypeKind.UNION;
}
@@ -1003,6 +1016,11 @@ public abstract class Type extends AnnoConstruct implements TypeMirror {
return interfaces_field.prepend(supertype_field);
}
+ @Override
+ public boolean isIntersection() {
+ return true;
+ }
+
public List<Type> getExplicitComponents() {
return allInterfaces ?
interfaces_field :
diff --git a/src/share/classes/com/sun/tools/javac/code/Types.java b/src/share/classes/com/sun/tools/javac/code/Types.java
index a9354648..d7110fbd 100644
--- a/src/share/classes/com/sun/tools/javac/code/Types.java
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java
@@ -47,6 +47,7 @@ import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.*;
import static com.sun.tools.javac.code.BoundKind.*;
import static com.sun.tools.javac.code.Flags.*;
+import static com.sun.tools.javac.code.Kinds.MTH;
import static com.sun.tools.javac.code.Scope.*;
import static com.sun.tools.javac.code.Symbol.*;
import static com.sun.tools.javac.code.Type.*;
@@ -85,6 +86,7 @@ public class Types {
final boolean allowBoxing;
final boolean allowCovariantReturns;
final boolean allowObjectToPrimitiveCast;
+ final boolean allowDefaultMethods;
final ClassReader reader;
final Check chk;
final Enter enter;
@@ -111,6 +113,7 @@ public class Types {
allowBoxing = source.allowBoxing();
allowCovariantReturns = source.allowCovariantReturns();
allowObjectToPrimitiveCast = source.allowObjectToPrimitiveCast();
+ allowDefaultMethods = source.allowDefaultMethods();
reader = ClassReader.instance(context);
chk = Check.instance(context);
enter = Enter.instance(context);
@@ -1536,8 +1539,8 @@ public class Types {
}
}
- if (t.isCompound() || s.isCompound()) {
- return !t.isCompound() ?
+ if (t.isIntersection() || s.isIntersection()) {
+ return !t.isIntersection() ?
visitIntersectionType((IntersectionClassType)s.unannotatedType(), t, true) :
visitIntersectionType((IntersectionClassType)t.unannotatedType(), s, false);
}
@@ -2252,19 +2255,28 @@ public class Types {
}
// </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="makeCompoundType">
+ // <editor-fold defaultstate="collapsed" desc="makeIntersectionType">
/**
- * Make a compound type from non-empty list of types. The list should be
- * ordered according to {@link Symbol#precedes(TypeSymbol,Types)}.
+ * Make an intersection type from non-empty list of types. The list should be ordered according to
+ * {@link TypeSymbol#precedes(TypeSymbol, Types)}. Note that this might cause a symbol completion.
+ * Hence, this version of makeIntersectionType may not be called during a classfile read.
*
- * @param bounds the types from which the compound type is formed
- * @param supertype is objectType if all bounds are interfaces,
- * null otherwise.
+ * @param bounds the types from which the intersection type is formed
*/
- public Type makeCompoundType(List<Type> bounds) {
- return makeCompoundType(bounds, bounds.head.tsym.isInterface());
+ public IntersectionClassType makeIntersectionType(List<Type> bounds) {
+ return makeIntersectionType(bounds, bounds.head.tsym.isInterface());
}
- public Type makeCompoundType(List<Type> bounds, boolean allInterfaces) {
+
+ /**
+ * Make an intersection type from non-empty list of types. The list should be ordered according to
+ * {@link TypeSymbol#precedes(TypeSymbol, Types)}. This does not cause symbol completion as
+ * an extra parameter indicates as to whether all bounds are interfaces - in which case the
+ * supertype is implicitly assumed to be 'Object'.
+ *
+ * @param bounds the types from which the intersection type is formed
+ * @param allInterfaces are all bounds interface types?
+ */
+ public IntersectionClassType makeIntersectionType(List<Type> bounds, boolean allInterfaces) {
Assert.check(bounds.nonEmpty());
Type firstExplicitBound = bounds.head;
if (allInterfaces) {
@@ -2277,23 +2289,24 @@ public class Types {
: names.empty,
null,
syms.noSymbol);
- bc.type = new IntersectionClassType(bounds, bc, allInterfaces);
+ IntersectionClassType intersectionType = new IntersectionClassType(bounds, bc, allInterfaces);
+ bc.type = intersectionType;
bc.erasure_field = (bounds.head.hasTag(TYPEVAR)) ?
syms.objectType : // error condition, recover
erasure(firstExplicitBound);
bc.members_field = new Scope(bc);
- return bc.type;
+ return intersectionType;
}
/**
- * A convenience wrapper for {@link #makeCompoundType(List)}; the
+ * A convenience wrapper for {@link #makeIntersectionType(List)}; the
* arguments are converted to a list and passed to the other
* method. Note that this might cause a symbol completion.
- * Hence, this version of makeCompoundType may not be called
+ * Hence, this version of makeIntersectionType may not be called
* during a classfile read.
*/
- public Type makeCompoundType(Type bound1, Type bound2) {
- return makeCompoundType(List.of(bound1, bound2));
+ public Type makeIntersectionType(Type bound1, Type bound2) {
+ return makeIntersectionType(List.of(bound1, bound2));
}
// </editor-fold>
@@ -2433,7 +2446,7 @@ public class Types {
private final UnaryVisitor<List<Type>> directSupertypes = new UnaryVisitor<List<Type>>() {
public List<Type> visitType(final Type type, final Void ignored) {
- if (!type.isCompound()) {
+ if (!type.isIntersection()) {
final Type sup = supertype(type);
return (sup == Type.noType || sup == type || sup == null)
? interfaces(type)
@@ -2487,30 +2500,32 @@ public class Types {
// <editor-fold defaultstate="collapsed" desc="setBounds">
/**
- * Set the bounds field of the given type variable to reflect a
- * (possibly multiple) list of bounds.
- * @param t a type variable
- * @param bounds the bounds, must be nonempty
- * @param supertype is objectType if all bounds are interfaces,
- * null otherwise.
+ * Same as {@link Types#setBounds(TypeVar, List, boolean)}, except that third parameter is computed directly,
+ * as follows: if all all bounds are interface types, the computed supertype is Object,otherwise
+ * the supertype is simply left null (in this case, the supertype is assumed to be the head of
+ * the bound list passed as second argument). Note that this check might cause a symbol completion.
+ * Hence, this version of setBounds may not be called during a classfile read.
+ *
+ * @param t a type variable
+ * @param bounds the bounds, must be nonempty
*/
public void setBounds(TypeVar t, List<Type> bounds) {
setBounds(t, bounds, bounds.head.tsym.isInterface());
}
/**
- * Same as {@link #setBounds(Type.TypeVar,List,Type)}, except that
- * third parameter is computed directly, as follows: if all
- * all bounds are interface types, the computed supertype is Object,
- * otherwise the supertype is simply left null (in this case, the supertype
- * is assumed to be the head of the bound list passed as second argument).
- * Note that this check might cause a symbol completion. Hence, this version of
- * setBounds may not be called during a classfile read.
+ * Set the bounds field of the given type variable to reflect a (possibly multiple) list of bounds.
+ * This does not cause symbol completion as an extra parameter indicates as to whether all bounds
+ * are interfaces - in which case the supertype is implicitly assumed to be 'Object'.
+ *
+ * @param t a type variable
+ * @param bounds the bounds, must be nonempty
+ * @param allInterfaces are all bounds interface types?
*/
public void setBounds(TypeVar t, List<Type> bounds, boolean allInterfaces) {
t.bound = bounds.tail.isEmpty() ?
bounds.head :
- makeCompoundType(bounds, allInterfaces);
+ makeIntersectionType(bounds, allInterfaces);
t.rank_field = -1;
}
// </editor-fold>
@@ -2691,78 +2706,155 @@ public class Types {
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="compute transitive closure of all members in given site">
- class MembersClosureCache extends SimpleVisitor<CompoundScope, Boolean> {
+ class MembersClosureCache extends SimpleVisitor<Scope.CompoundScope, Void> {
- private WeakHashMap<TypeSymbol, Entry> _map =
- new WeakHashMap<TypeSymbol, Entry>();
+ private Map<TypeSymbol, CompoundScope> _map = new HashMap<>();
- class Entry {
- final boolean skipInterfaces;
- final CompoundScope compoundScope;
+ Set<TypeSymbol> seenTypes = new HashSet<>();
+
+ class MembersScope extends CompoundScope {
+
+ CompoundScope scope;
+
+ public MembersScope(CompoundScope scope) {
+ super(scope.owner);
+ this.scope = scope;
+ }
+
+ Filter<Symbol> combine(final Filter<Symbol> sf) {
+ return new Filter<Symbol>() {
+ @Override
+ public boolean accepts(Symbol s) {
+ return !s.owner.isInterface() && (sf == null || sf.accepts(s));
+ }
+ };
+ }
+
+ @Override
+ public Iterable<Symbol> getElements(Filter<Symbol> sf) {
+ return scope.getElements(combine(sf));
+ }
- public Entry(boolean skipInterfaces, CompoundScope compoundScope) {
- this.skipInterfaces = skipInterfaces;
- this.compoundScope = compoundScope;
+ @Override
+ public Iterable<Symbol> getElementsByName(Name name, Filter<Symbol> sf) {
+ return scope.getElementsByName(name, combine(sf));
}
- boolean matches(boolean skipInterfaces) {
- return this.skipInterfaces == skipInterfaces;
+ @Override
+ public int getMark() {
+ return scope.getMark();
}
}
- List<TypeSymbol> seenTypes = List.nil();
+ CompoundScope nilScope;
/** members closure visitor methods **/
- public CompoundScope visitType(Type t, Boolean skipInterface) {
- return null;
+ public CompoundScope visitType(Type t, Void _unused) {
+ if (nilScope == null) {
+ nilScope = new CompoundScope(syms.noSymbol);
+ }
+ return nilScope;
}
@Override
- public CompoundScope visitClassType(ClassType t, Boolean skipInterface) {
- if (seenTypes.contains(t.tsym)) {
+ public CompoundScope visitClassType(ClassType t, Void _unused) {
+ if (!seenTypes.add(t.tsym)) {
//this is possible when an interface is implemented in multiple
- //superclasses, or when a classs hierarchy is circular - in such
+ //superclasses, or when a class hierarchy is circular - in such
//cases we don't need to recurse (empty scope is returned)
return new CompoundScope(t.tsym);
}
try {
- seenTypes = seenTypes.prepend(t.tsym);
+ seenTypes.add(t.tsym);
ClassSymbol csym = (ClassSymbol)t.tsym;
- Entry e = _map.get(csym);
- if (e == null || !e.matches(skipInterface)) {
- CompoundScope membersClosure = new CompoundScope(csym);
- if (!skipInterface) {
- for (Type i : interfaces(t)) {
- membersClosure.addSubScope(visit(i, skipInterface));
- }
+ CompoundScope membersClosure = _map.get(csym);
+ if (membersClosure == null) {
+ membersClosure = new CompoundScope(csym);
+ for (Type i : interfaces(t)) {
+ membersClosure.addSubScope(visit(i, null));
}
- membersClosure.addSubScope(visit(supertype(t), skipInterface));
+ membersClosure.addSubScope(visit(supertype(t), null));
membersClosure.addSubScope(csym.members());
- e = new Entry(skipInterface, membersClosure);
- _map.put(csym, e);
+ _map.put(csym, membersClosure);
}
- return e.compoundScope;
+ return membersClosure;
}
finally {
- seenTypes = seenTypes.tail;
+ seenTypes.remove(t.tsym);
}
}
@Override
- public CompoundScope visitTypeVar(TypeVar t, Boolean skipInterface) {
- return visit(t.getUpperBound(), skipInterface);
+ public CompoundScope visitTypeVar(TypeVar t, Void _unused) {
+ return visit(t.getUpperBound(), null);
}
}
private MembersClosureCache membersCache = new MembersClosureCache();
public CompoundScope membersClosure(Type site, boolean skipInterface) {
- return membersCache.visit(site, skipInterface);
+ CompoundScope cs = membersCache.visit(site, null);
+ if (cs == null)
+ Assert.error("type " + site);
+ return skipInterface ? membersCache.new MembersScope(cs) : cs;
}
// </editor-fold>
+ /** Return first abstract member of class `sym'.
+ */
+ public MethodSymbol firstUnimplementedAbstract(ClassSymbol sym) {
+ try {
+ return firstUnimplementedAbstractImpl(sym, sym);
+ } catch (CompletionFailure ex) {
+ chk.completionError(enter.getEnv(sym).tree.pos(), ex);
+ return null;
+ }
+ }
+ //where:
+ private MethodSymbol firstUnimplementedAbstractImpl(ClassSymbol impl, ClassSymbol c) {
+ MethodSymbol undef = null;
+ // Do not bother to search in classes that are not abstract,
+ // since they cannot have abstract members.
+ if (c == impl || (c.flags() & (ABSTRACT | INTERFACE)) != 0) {
+ Scope s = c.members();
+ for (Scope.Entry e = s.elems;
+ undef == null && e != null;
+ e = e.sibling) {
+ if (e.sym.kind == MTH &&
+ (e.sym.flags() & (ABSTRACT|IPROXY|DEFAULT)) == ABSTRACT) {
+ MethodSymbol absmeth = (MethodSymbol)e.sym;
+ MethodSymbol implmeth = absmeth.implementation(impl, this, true);
+ if (implmeth == null || implmeth == absmeth) {
+ //look for default implementations
+ if (allowDefaultMethods) {
+ MethodSymbol prov = interfaceCandidates(impl.type, absmeth).head;
+ if (prov != null && prov.overrides(absmeth, impl, this, true)) {
+ implmeth = prov;
+ }
+ }
+ }
+ if (implmeth == null || implmeth == absmeth) {
+ undef = absmeth;
+ }
+ }
+ }
+ if (undef == null) {
+ Type st = supertype(c.type);
+ if (st.hasTag(CLASS))
+ undef = firstUnimplementedAbstractImpl(impl, (ClassSymbol)st.tsym);
+ }
+ for (List<Type> l = interfaces(c.type);
+ undef == null && l.nonEmpty();
+ l = l.tail) {
+ undef = firstUnimplementedAbstractImpl(impl, (ClassSymbol)l.head.tsym);
+ }
+ }
+ return undef;
+ }
+
+
//where
public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms) {
Filter<Symbol> filter = new MethodFilter(ms, site);
@@ -2983,7 +3075,7 @@ public class Types {
if (st == supertype(t) && is == interfaces(t))
return t;
else
- return makeCompoundType(is.prepend(st));
+ return makeIntersectionType(is.prepend(st));
}
}
@@ -3486,7 +3578,7 @@ public class Types {
else if (compound.tail.isEmpty())
return compound.head;
else
- return makeCompoundType(compound);
+ return makeIntersectionType(compound);
}
/**
@@ -3664,8 +3756,8 @@ public class Types {
synchronized (this) {
if (arraySuperType == null) {
// JLS 10.8: all arrays implement Cloneable and Serializable.
- arraySuperType = makeCompoundType(List.of(syms.serializableType,
- syms.cloneableType), true);
+ arraySuperType = makeIntersectionType(List.of(syms.serializableType,
+ syms.cloneableType), true);
}
}
}
@@ -3731,7 +3823,7 @@ public class Types {
return glbFlattened(union(bounds, lowers), errT);
}
}
- return makeCompoundType(bounds);
+ return makeIntersectionType(bounds);
}
// </editor-fold>
diff --git a/src/share/classes/com/sun/tools/javac/comp/Attr.java b/src/share/classes/com/sun/tools/javac/comp/Attr.java
index f5d52595..a88b6a0f 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -156,6 +156,8 @@ public class Attr extends JCTree.Visitor {
unknownTypeInfo = new ResultInfo(TYP, Type.noType);
unknownTypeExprInfo = new ResultInfo(Kinds.TYP | Kinds.VAL, Type.noType);
recoveryInfo = new RecoveryInfo(deferredAttr.emptyDeferredAttrContext);
+
+ noCheckTree = make.at(-1).Skip();
}
/** Switch: relax some constraints for retrofit mode.
@@ -253,31 +255,34 @@ public class Attr extends JCTree.Visitor {
Type check(final JCTree tree, final Type found, final int ownkind, final ResultInfo resultInfo) {
InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
Type owntype;
- if (!found.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) {
- if ((ownkind & ~resultInfo.pkind) != 0) {
- log.error(tree.pos(), "unexpected.type",
+ boolean shouldCheck = !found.hasTag(ERROR) &&
+ !resultInfo.pt.hasTag(METHOD) &&
+ !resultInfo.pt.hasTag(FORALL);
+ if (shouldCheck && (ownkind & ~resultInfo.pkind) != 0) {
+ log.error(tree.pos(), "unexpected.type",
kindNames(resultInfo.pkind),
kindName(ownkind));
- owntype = types.createErrorType(found);
- } else if (allowPoly && inferenceContext.free(found)) {
- //delay the check if there are inference variables in the found type
- //this means we are dealing with a partially inferred poly expression
- owntype = resultInfo.pt;
- inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), new FreeTypeListener() {
+ owntype = types.createErrorType(found);
+ } else if (allowPoly && inferenceContext.free(found)) {
+ //delay the check if there are inference variables in the found type
+ //this means we are dealing with a partially inferred poly expression
+ owntype = shouldCheck ? resultInfo.pt : found;
+ inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), new FreeTypeListener() {
@Override
public void typesInferred(InferenceContext inferenceContext) {
ResultInfo pendingResult =
resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
check(tree, inferenceContext.asInstType(found), ownkind, pendingResult);
}
- });
- } else {
- owntype = resultInfo.check(tree, found);
- }
+ });
} else {
- owntype = found;
+ owntype = shouldCheck ?
+ resultInfo.check(tree, found) :
+ found;
+ }
+ if (tree != noCheckTree) {
+ tree.type = owntype;
}
- tree.type = owntype;
return owntype;
}
@@ -550,6 +555,10 @@ public class Attr extends JCTree.Visitor {
*/
Type result;
+ /** Synthetic tree to be used during 'fake' checks.
+ */
+ JCTree noCheckTree;
+
/** Visitor method: attribute a tree, catching any completion failure
* exceptions. Return the tree's type.
*
@@ -653,8 +662,8 @@ public class Attr extends JCTree.Visitor {
/** Attribute the arguments in a method call, returning the method kind.
*/
- int attribArgs(List<JCExpression> trees, Env<AttrContext> env, ListBuffer<Type> argtypes) {
- int kind = VAL;
+ int attribArgs(int initialKind, List<JCExpression> trees, Env<AttrContext> env, ListBuffer<Type> argtypes) {
+ int kind = initialKind;
for (JCExpression arg : trees) {
Type argtype;
if (allowPoly && deferredAttr.isDeferred(env, arg)) {
@@ -825,9 +834,18 @@ public class Attr extends JCTree.Visitor {
}
public void visitClassDef(JCClassDecl tree) {
- // Local classes have not been entered yet, so we need to do it now:
- if ((env.info.scope.owner.kind & (VAR | MTH)) != 0)
+ // Local and anonymous classes have not been entered yet, so we need to
+ // do it now.
+ if ((env.info.scope.owner.kind & (VAR | MTH)) != 0) {
enter.classEnter(tree, env);
+ } else {
+ // If this class declaration is part of a class level annotation,
+ // as in @MyAnno(new Object() {}) class MyClass {}, enter it in
+ // order to simplify later steps and allow for sensible error
+ // messages.
+ if (env.tree.hasTag(NEWCLASS) && TreeInfo.isInAnnotation(env, tree))
+ enter.classEnter(tree, env);
+ }
ClassSymbol c = tree.sym;
if (c == null) {
@@ -1721,7 +1739,7 @@ public class Attr extends JCTree.Visitor {
localEnv.info.isSelfCall = true;
// Attribute arguments, yielding list of argument types.
- attribArgs(tree.args, localEnv, argtypesBuf);
+ int kind = attribArgs(MTH, tree.args, localEnv, argtypesBuf);
argtypes = argtypesBuf.toList();
typeargtypes = attribTypes(tree.typeargs, localEnv);
@@ -1786,7 +1804,7 @@ public class Attr extends JCTree.Visitor {
// ...and check that it is legal in the current context.
// (this will also set the tree's type)
Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes);
- checkId(tree.meth, site, sym, localEnv, new ResultInfo(MTH, mpt));
+ checkId(tree.meth, site, sym, localEnv, new ResultInfo(kind, mpt));
}
// Otherwise, `site' is an error type and we do nothing
}
@@ -1794,7 +1812,7 @@ public class Attr extends JCTree.Visitor {
} else {
// Otherwise, we are seeing a regular method call.
// Attribute the arguments, yielding list of argument types, ...
- int kind = attribArgs(tree.args, localEnv, argtypesBuf);
+ int kind = attribArgs(VAL, tree.args, localEnv, argtypesBuf);
argtypes = argtypesBuf.toList();
typeargtypes = attribAnyTypes(tree.typeargs, localEnv);
@@ -1976,7 +1994,7 @@ public class Attr extends JCTree.Visitor {
// Attribute constructor arguments.
ListBuffer<Type> argtypesBuf = new ListBuffer<>();
- int pkind = attribArgs(tree.args, localEnv, argtypesBuf);
+ int pkind = attribArgs(VAL, tree.args, localEnv, argtypesBuf);
List<Type> argtypes = argtypesBuf.toList();
List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
@@ -2034,7 +2052,7 @@ public class Attr extends JCTree.Visitor {
}
});
Type constructorType = tree.constructorType = types.createErrorType(clazztype);
- constructorType = checkId(tree, site,
+ constructorType = checkId(noCheckTree, site,
constructor,
diamondEnv,
diamondResult);
@@ -2060,7 +2078,7 @@ public class Attr extends JCTree.Visitor {
tree.constructor = rs.resolveConstructor(
tree.pos(), rsEnv, clazztype, argtypes, typeargtypes);
if (cdef == null) { //do not check twice!
- tree.constructorType = checkId(tree,
+ tree.constructorType = checkId(noCheckTree,
clazztype,
tree.constructor,
rsEnv,
@@ -2141,7 +2159,7 @@ public class Attr extends JCTree.Visitor {
tree.pos(), localEnv, clazztype, argtypes, typeargtypes);
Assert.check(sym.kind < AMBIGUOUS);
tree.constructor = sym;
- tree.constructorType = checkId(tree,
+ tree.constructorType = checkId(noCheckTree,
clazztype,
tree.constructor,
localEnv,
@@ -2152,6 +2170,17 @@ public class Attr extends JCTree.Visitor {
owntype = clazztype;
}
result = check(tree, owntype, VAL, resultInfo);
+ InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
+ if (tree.constructorType != null && inferenceContext.free(tree.constructorType)) {
+ //we need to wait for inference to finish and then replace inference vars in the constructor type
+ inferenceContext.addFreeTypeListener(List.of(tree.constructorType),
+ new FreeTypeListener() {
+ @Override
+ public void typesInferred(InferenceContext instantiatedContext) {
+ tree.constructorType = instantiatedContext.asInstType(tree.constructorType);
+ }
+ });
+ }
chk.validate(tree.typeargs, localEnv);
}
//where
@@ -2379,6 +2408,7 @@ public class Attr extends JCTree.Visitor {
preFlow(that);
flow.analyzeLambda(env, that, make, isSpeculativeRound);
+ that.type = currentTarget; //avoids recovery at this stage
checkLambdaCompatible(that, lambdaType, resultInfo.checkContext);
if (!isSpeculativeRound) {
@@ -2425,7 +2455,7 @@ public class Attr extends JCTree.Visitor {
@Override
public Type visitClassType(ClassType t, DiagnosticPosition pos) {
- return t.isCompound() ?
+ return t.isIntersection() ?
visitIntersectionClassType((IntersectionClassType)t, pos) : t;
}
@@ -2456,8 +2486,7 @@ public class Attr extends JCTree.Visitor {
}
supertypes.append(i.tsym.type);
}
- IntersectionClassType notionalIntf =
- (IntersectionClassType)types.makeCompoundType(supertypes.toList());
+ IntersectionClassType notionalIntf = types.makeIntersectionType(supertypes.toList());
notionalIntf.allparams_field = targs.toList();
notionalIntf.tsym.flags_field |= INTERFACE;
return notionalIntf.tsym;
@@ -2818,7 +2847,7 @@ public class Attr extends JCTree.Visitor {
that.kind.isUnbound() ? argtypes.tail : argtypes, typeargtypes),
new FunctionalReturnContext(resultInfo.checkContext));
- Type refType = checkId(that, lookupHelper.site, refSym, localEnv, checkInfo);
+ Type refType = checkId(noCheckTree, lookupHelper.site, refSym, localEnv, checkInfo);
if (that.kind.isUnbound() &&
resultInfo.checkContext.inferenceContext().free(argtypes.head)) {
@@ -2840,6 +2869,8 @@ public class Attr extends JCTree.Visitor {
//is a no-op (as this has been taken care during method applicability)
boolean isSpeculativeRound =
resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
+
+ that.type = currentTarget; //avoids recovery at this stage
checkReferenceCompatible(that, desc, refType, resultInfo.checkContext, isSpeculativeRound);
if (!isSpeculativeRound) {
checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, currentTarget);
@@ -3960,7 +3991,7 @@ public class Attr extends JCTree.Visitor {
all_multicatchTypes.append(ctype);
}
}
- Type t = check(tree, types.lub(multicatchTypes.toList()), TYP, resultInfo);
+ Type t = check(noCheckTree, types.lub(multicatchTypes.toList()), TYP, resultInfo);
if (t.hasTag(CLASS)) {
List<Type> alternatives =
((all_multicatchTypes == null) ? multicatchTypes : all_multicatchTypes).toList();
@@ -4023,7 +4054,7 @@ public class Attr extends JCTree.Visitor {
} else if (bounds.length() == 1) {
return bounds.head.type;
} else {
- Type owntype = types.makeCompoundType(TreeInfo.types(bounds));
+ Type owntype = types.makeIntersectionType(TreeInfo.types(bounds));
// ... the variable's bound is a class type flagged COMPOUND
// (see comment for TypeVar.bound).
// In this case, generate a class tree that represents the
@@ -4269,6 +4300,8 @@ public class Attr extends JCTree.Visitor {
chk.validate(tree.implementing, env);
}
+ c.markAbstractIfNeeded(types);
+
// If this is a non-abstract class, check that it has no abstract
// methods or unimplemented methods of an implemented interface.
if ((c.flags() & (ABSTRACT | INTERFACE)) == 0) {
diff --git a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java
index e9e6224d..0f7cd603 100644
--- a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java
+++ b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java
@@ -25,6 +25,7 @@
package com.sun.tools.javac.comp;
+import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.code.*;
@@ -80,6 +81,13 @@ public class AttrContext {
*/
Type defaultSuperCallSite = null;
+ /** Tree that when non null, is to be preferentially used in diagnostics.
+ * Usually Env<AttrContext>.tree is the tree to be referred to in messages,
+ * but this may not be true during the window a method is looked up in enclosing
+ * contexts (JDK-8145466)
+ */
+ JCTree preferredTreeForDiagnostics;
+
/** Duplicate this context, replacing scope field and copying all others.
*/
AttrContext dup(Scope scope) {
@@ -94,6 +102,7 @@ public class AttrContext {
info.returnResult = returnResult;
info.defaultSuperCallSite = defaultSuperCallSite;
info.isSerializable = isSerializable;
+ info.preferredTreeForDiagnostics = preferredTreeForDiagnostics;
return info;
}
diff --git a/src/share/classes/com/sun/tools/javac/comp/Check.java b/src/share/classes/com/sun/tools/javac/comp/Check.java
index 141b5573..d5e9c47a 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java
@@ -1813,7 +1813,7 @@ public class Check {
Type t1,
Type t2) {
return checkCompatibleAbstracts(pos, t1, t2,
- types.makeCompoundType(t1, t2));
+ types.makeIntersectionType(t1, t2));
}
public boolean checkCompatibleAbstracts(DiagnosticPosition pos,
@@ -2049,70 +2049,15 @@ public class Check {
* @param c The class.
*/
void checkAllDefined(DiagnosticPosition pos, ClassSymbol c) {
- try {
- MethodSymbol undef = firstUndef(c, c);
- if (undef != null) {
- if ((c.flags() & ENUM) != 0 &&
- types.supertype(c.type).tsym == syms.enumSym &&
- (c.flags() & FINAL) == 0) {
- // add the ABSTRACT flag to an enum
- c.flags_field |= ABSTRACT;
- } else {
- MethodSymbol undef1 =
- new MethodSymbol(undef.flags(), undef.name,
- types.memberType(c.type, undef), undef.owner);
- log.error(pos, "does.not.override.abstract",
- c, undef1, undef1.location());
- }
- }
- } catch (CompletionFailure ex) {
- completionError(pos, ex);
+ MethodSymbol undef = types.firstUnimplementedAbstract(c);
+ if (undef != null) {
+ MethodSymbol undef1 =
+ new MethodSymbol(undef.flags(), undef.name,
+ types.memberType(c.type, undef), undef.owner);
+ log.error(pos, "does.not.override.abstract",
+ c, undef1, undef1.location());
}
}
-//where
- /** Return first abstract member of class `c' that is not defined
- * in `impl', null if there is none.
- */
- private MethodSymbol firstUndef(ClassSymbol impl, ClassSymbol c) {
- MethodSymbol undef = null;
- // Do not bother to search in classes that are not abstract,
- // since they cannot have abstract members.
- if (c == impl || (c.flags() & (ABSTRACT | INTERFACE)) != 0) {
- Scope s = c.members();
- for (Scope.Entry e = s.elems;
- undef == null && e != null;
- e = e.sibling) {
- if (e.sym.kind == MTH &&
- (e.sym.flags() & (ABSTRACT|IPROXY|DEFAULT)) == ABSTRACT) {
- MethodSymbol absmeth = (MethodSymbol)e.sym;
- MethodSymbol implmeth = absmeth.implementation(impl, types, true);
- if (implmeth == null || implmeth == absmeth) {
- //look for default implementations
- if (allowDefaultMethods) {
- MethodSymbol prov = types.interfaceCandidates(impl.type, absmeth).head;
- if (prov != null && prov.overrides(absmeth, impl, types, true)) {
- implmeth = prov;
- }
- }
- }
- if (implmeth == null || implmeth == absmeth) {
- undef = absmeth;
- }
- }
- }
- if (undef == null) {
- Type st = types.supertype(c.type);
- if (st.hasTag(CLASS))
- undef = firstUndef(impl, (ClassSymbol)st.tsym);
- }
- for (List<Type> l = types.interfaces(c.type);
- undef == null && l.nonEmpty();
- l = l.tail) {
- undef = firstUndef(impl, (ClassSymbol)l.head.tsym);
- }
- }
- return undef;
- }
void checkNonCyclicDecl(JCClassDecl tree) {
CycleChecker cc = new CycleChecker();
diff --git a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
index a8946e4e..c67715e4 100644
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
+++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -224,7 +224,8 @@ public class DeferredAttr extends JCTree.Visitor {
DeferredStuckPolicy deferredStuckPolicy;
if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) {
deferredStuckPolicy = dummyStuckPolicy;
- } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) {
+ } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE ||
+ resultInfo.checkContext.deferredAttrContext().insideOverloadPhase()) {
deferredStuckPolicy = new OverloadStuckPolicy(resultInfo, this);
} else {
deferredStuckPolicy = new CheckStuckPolicy(resultInfo, this);
@@ -1255,6 +1256,9 @@ public class DeferredAttr extends JCTree.Visitor {
return isSimpleReceiver(((JCAnnotatedType)rec).underlyingType);
case APPLY:
return true;
+ case NEWCLASS:
+ JCNewClass nc = (JCNewClass) rec;
+ return nc.encl == null && nc.def == null && !TreeInfo.isDiamond(nc);
default:
return false;
}
@@ -1309,17 +1313,24 @@ public class DeferredAttr extends JCTree.Visitor {
Type site;
if (rec != null) {
- if (rec.hasTag(APPLY)) {
- Symbol recSym = quicklyResolveMethod(env, (JCMethodInvocation) rec);
- if (recSym == null)
- return null;
- Symbol resolvedReturnType =
- analyzeCandidateMethods(recSym, syms.errSymbol, returnSymbolAnalyzer);
- if (resolvedReturnType == null)
- return null;
- site = resolvedReturnType.type;
- } else {
- site = attribSpeculative(rec, env, attr.unknownTypeExprInfo).type;
+ switch (rec.getTag()) {
+ case APPLY:
+ Symbol recSym = quicklyResolveMethod(env, (JCMethodInvocation) rec);
+ if (recSym == null)
+ return null;
+ Symbol resolvedReturnType =
+ analyzeCandidateMethods(recSym, syms.errSymbol, returnSymbolAnalyzer);
+ if (resolvedReturnType == null)
+ return null;
+ site = resolvedReturnType.type;
+ break;
+ case NEWCLASS:
+ JCNewClass nc = (JCNewClass) rec;
+ site = attribSpeculative(nc.clazz, env, attr.unknownTypeExprInfo).type;
+ break;
+ default:
+ site = attribSpeculative(rec, env, attr.unknownTypeExprInfo).type;
+ break;
}
} else {
site = env.enclClass.sym.type;
diff --git a/src/share/classes/com/sun/tools/javac/comp/Flow.java b/src/share/classes/com/sun/tools/javac/comp/Flow.java
index 0406d0be..6fdfada5 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Flow.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -353,17 +353,17 @@ public class Flow {
this.tree = tree;
}
- void resolveJump(JCTree tree) {
+ void resolveJump() {
//do nothing
}
}
- abstract void markDead(JCTree tree);
+ abstract void markDead();
/** Record an outward transfer of control. */
- void recordExit(JCTree tree, P pe) {
+ void recordExit(P pe) {
pendingExits.append(pe);
- markDead(tree);
+ markDead();
}
/** Resolve all jumps of this statement. */
@@ -377,7 +377,7 @@ public class Flow {
P exit = exits.head;
if (exit.tree.hasTag(jk.treeTag) &&
jk.getTarget(exit.tree) == tree) {
- exit.resolveJump(tree);
+ exit.resolveJump();
resolved = true;
} else {
pendingExits.append(exit);
@@ -420,7 +420,7 @@ public class Flow {
private boolean alive;
@Override
- void markDead(JCTree tree) {
+ void markDead() {
alive = false;
}
@@ -464,7 +464,7 @@ public class Flow {
ListBuffer<PendingExit> pendingExitsPrev = pendingExits;
Lint lintPrev = lint;
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
lint = lint.augment(tree.sym);
try {
@@ -513,7 +513,7 @@ public class Flow {
log.error(TreeInfo.diagEndPos(tree.body), "missing.ret.stmt");
List<PendingExit> exits = pendingExits.toList();
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
while (exits.nonEmpty()) {
PendingExit exit = exits.head;
exits = exits.tail;
@@ -542,7 +542,7 @@ public class Flow {
public void visitDoLoop(JCDoWhileLoop tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
scanStat(tree.body);
alive |= resolveContinues(tree);
scan(tree.cond);
@@ -552,7 +552,7 @@ public class Flow {
public void visitWhileLoop(JCWhileLoop tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
scan(tree.cond);
alive = !tree.cond.type.isFalse();
scanStat(tree.body);
@@ -564,7 +564,7 @@ public class Flow {
public void visitForLoop(JCForLoop tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
scanStats(tree.init);
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
if (tree.cond != null) {
scan(tree.cond);
alive = !tree.cond.type.isFalse();
@@ -582,7 +582,7 @@ public class Flow {
visitVarDef(tree.var);
ListBuffer<PendingExit> prevPendingExits = pendingExits;
scan(tree.expr);
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
scanStat(tree.body);
alive |= resolveContinues(tree);
resolveBreaks(tree, prevPendingExits);
@@ -591,14 +591,14 @@ public class Flow {
public void visitLabelled(JCLabeledStatement tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
scanStat(tree.body);
alive |= resolveBreaks(tree, prevPendingExits);
}
public void visitSwitch(JCSwitch tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
scan(tree.selector);
boolean hasDefault = false;
for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
@@ -625,7 +625,7 @@ public class Flow {
public void visitTry(JCTry tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
for (JCTree resource : tree.resources) {
if (resource instanceof JCVariableDecl) {
JCVariableDecl vdecl = (JCVariableDecl) resource;
@@ -688,21 +688,21 @@ public class Flow {
}
public void visitBreak(JCBreak tree) {
- recordExit(tree, new PendingExit(tree));
+ recordExit(new PendingExit(tree));
}
public void visitContinue(JCContinue tree) {
- recordExit(tree, new PendingExit(tree));
+ recordExit(new PendingExit(tree));
}
public void visitReturn(JCReturn tree) {
scan(tree.expr);
- recordExit(tree, new PendingExit(tree));
+ recordExit(new PendingExit(tree));
}
public void visitThrow(JCThrow tree) {
scan(tree.expr);
- markDead(tree);
+ markDead();
}
public void visitApply(JCMethodInvocation tree) {
@@ -756,7 +756,7 @@ public class Flow {
try {
attrEnv = env;
Flow.this.make = make;
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
alive = true;
scan(tree);
} finally {
@@ -803,7 +803,7 @@ public class Flow {
}
@Override
- void markDead(JCTree tree) {
+ void markDead() {
//do nothing
}
@@ -1201,16 +1201,16 @@ public class Flow {
}
public void visitBreak(JCBreak tree) {
- recordExit(tree, new FlowPendingExit(tree, null));
+ recordExit(new FlowPendingExit(tree, null));
}
public void visitContinue(JCContinue tree) {
- recordExit(tree, new FlowPendingExit(tree, null));
+ recordExit(new FlowPendingExit(tree, null));
}
public void visitReturn(JCReturn tree) {
scan(tree.expr);
- recordExit(tree, new FlowPendingExit(tree, null));
+ recordExit(new FlowPendingExit(tree, null));
}
public void visitThrow(JCThrow tree) {
@@ -1228,7 +1228,7 @@ public class Flow {
else {
markThrown(tree, tree.expr.type);
}
- markDead(tree);
+ markDead();
}
public void visitApply(JCMethodInvocation tree) {
@@ -1379,12 +1379,10 @@ public class Flow {
* effectively-final local variables/parameters.
*/
- public abstract class AbstractAssignAnalyzer<P extends AbstractAssignAnalyzer<P>.AbstractAssignPendingExit>
- extends BaseAnalyzer<P> {
-
+ public class AssignAnalyzer extends BaseAnalyzer<AssignAnalyzer.AssignPendingExit> {
/** The set of definitely assigned variables.
*/
- protected Bits inits;
+ final Bits inits;
/** The set of definitely unassigned variables.
*/
@@ -1432,20 +1430,20 @@ public class Flow {
*/
Scope unrefdResources;
- /** Set when processing a loop body the second time for DU analysis. */
+ /** Modified when processing a loop body the second time for DU analysis. */
FlowKind flowKind = FlowKind.NORMAL;
- /** The starting position of the analysed tree */
+ /** The starting position of the analyzed tree */
int startPos;
- public class AbstractAssignPendingExit extends BaseAnalyzer.PendingExit {
+ public class AssignPendingExit extends BaseAnalyzer.PendingExit {
final Bits inits;
final Bits uninits;
final Bits exit_inits = new Bits(true);
final Bits exit_uninits = new Bits(true);
- public AbstractAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) {
+ public AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) {
super(tree);
this.inits = inits;
this.uninits = uninits;
@@ -1454,13 +1452,13 @@ public class Flow {
}
@Override
- public void resolveJump(JCTree tree) {
+ void resolveJump() {
inits.andSet(exit_inits);
uninits.andSet(exit_uninits);
}
}
- public AbstractAssignAnalyzer() {
+ public AssignAnalyzer() {
this.inits = new Bits();
uninits = new Bits();
uninitsTry = new Bits();
@@ -1473,7 +1471,7 @@ public class Flow {
private boolean isInitialConstructor = false;
@Override
- protected void markDead(JCTree tree) {
+ void markDead() {
if (!isInitialConstructor) {
inits.inclRange(returnadr, nextadr);
} else {
@@ -1520,35 +1518,41 @@ public class Flow {
}
sym.adr = nextadr;
vardecls[nextadr] = varDecl;
- exclVarFromInits(varDecl, nextadr);
+ inits.excl(nextadr);
uninits.incl(nextadr);
nextadr++;
}
- protected void exclVarFromInits(JCTree tree, int adr) {
- inits.excl(adr);
- }
-
- protected void assignToInits(JCTree tree, Bits bits) {
- inits.assign(bits);
- }
-
- protected void andSetInits(JCTree tree, Bits bits) {
- inits.andSet(bits);
- }
-
- protected void orSetInits(JCTree tree, Bits bits) {
- inits.orSet(bits);
- }
-
/** Record an initialization of a trackable variable.
*/
void letInit(DiagnosticPosition pos, VarSymbol sym) {
if (sym.adr >= firstadr && trackable(sym)) {
- if (uninits.isMember(sym.adr)) {
- uninit(sym);
+ if ((sym.flags() & EFFECTIVELY_FINAL) != 0) {
+ if (!uninits.isMember(sym.adr)) {
+ //assignment targeting an effectively final variable
+ //makes the variable lose its status of effectively final
+ //if the variable is _not_ definitively unassigned
+ sym.flags_field &= ~EFFECTIVELY_FINAL;
+ } else {
+ uninit(sym);
+ }
+ } else if ((sym.flags() & FINAL) != 0) {
+ if ((sym.flags() & PARAMETER) != 0) {
+ if ((sym.flags() & UNION) != 0) { //multi-catch parameter
+ log.error(pos, "multicatch.parameter.may.not.be.assigned", sym);
+ } else {
+ log.error(pos, "final.parameter.may.not.be.assigned",
+ sym);
+ }
+ } else if (!uninits.isMember(sym.adr)) {
+ log.error(pos, flowKind.errKey, sym);
+ } else {
+ uninit(sym);
+ }
}
inits.incl(sym.adr);
+ } else if ((sym.flags() & FINAL) != 0) {
+ log.error(pos, "var.might.already.be.assigned", sym);
}
}
//where
@@ -1583,7 +1587,14 @@ public class Flow {
checkInit(pos, sym, "var.might.not.have.been.initialized");
}
- void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) {}
+ void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) {
+ if ((sym.adr >= firstadr || sym.owner.kind != TYP) &&
+ trackable(sym) &&
+ !inits.isMember(sym.adr)) {
+ log.error(pos, errkey, sym);
+ inits.incl(sym.adr);
+ }
+ }
/** Utility method to reset several Bits instances.
*/
@@ -1607,7 +1618,7 @@ public class Flow {
/** Merge (intersect) inits/uninits from WhenTrue/WhenFalse sets.
*/
- protected void merge(JCTree tree) {
+ protected void merge() {
inits.assign(initsWhenFalse.andSet(initsWhenTrue));
uninits.assign(uninitsWhenFalse.andSet(uninitsWhenTrue));
}
@@ -1623,7 +1634,7 @@ public class Flow {
if (tree != null) {
scan(tree);
if (inits.isReset()) {
- merge(tree);
+ merge();
}
}
}
@@ -1641,7 +1652,7 @@ public class Flow {
*/
void scanCond(JCTree tree) {
if (tree.type.isFalse()) {
- if (inits.isReset()) merge(tree);
+ if (inits.isReset()) merge();
initsWhenTrue.assign(inits);
initsWhenTrue.inclRange(firstadr, nextadr);
uninitsWhenTrue.assign(uninits);
@@ -1649,7 +1660,7 @@ public class Flow {
initsWhenFalse.assign(inits);
uninitsWhenFalse.assign(uninits);
} else if (tree.type.isTrue()) {
- if (inits.isReset()) merge(tree);
+ if (inits.isReset()) merge();
initsWhenFalse.assign(inits);
initsWhenFalse.inclRange(firstadr, nextadr);
uninitsWhenFalse.assign(uninits);
@@ -1668,173 +1679,202 @@ public class Flow {
/* ------------ Visitor methods for various sorts of trees -------------*/
- @Override
public void visitClassDef(JCClassDecl tree) {
if (tree.sym == null) {
return;
}
- JCClassDecl classDefPrev = classDef;
- int firstadrPrev = firstadr;
- int nextadrPrev = nextadr;
- ListBuffer<P> pendingExitsPrev = pendingExits;
-
- pendingExits = new ListBuffer<P>();
- if (tree.name != names.empty) {
- firstadr = nextadr;
- }
- classDef = tree;
+ Lint lintPrev = lint;
+ lint = lint.augment(tree.sym);
try {
- // define all the static fields
- for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
- if (l.head.hasTag(VARDEF)) {
- JCVariableDecl def = (JCVariableDecl)l.head;
- if ((def.mods.flags & STATIC) != 0) {
- VarSymbol sym = def.sym;
- if (trackable(sym)) {
- newVar(def);
+ if (tree.sym == null) {
+ return;
+ }
+
+ JCClassDecl classDefPrev = classDef;
+ int firstadrPrev = firstadr;
+ int nextadrPrev = nextadr;
+ ListBuffer<AssignPendingExit> pendingExitsPrev = pendingExits;
+
+ pendingExits = new ListBuffer<>();
+ if (tree.name != names.empty) {
+ firstadr = nextadr;
+ }
+ classDef = tree;
+ try {
+ // define all the static fields
+ for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+ if (l.head.hasTag(VARDEF)) {
+ JCVariableDecl def = (JCVariableDecl)l.head;
+ if ((def.mods.flags & STATIC) != 0) {
+ VarSymbol sym = def.sym;
+ if (trackable(sym)) {
+ newVar(def);
+ }
}
}
}
- }
- // process all the static initializers
- for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
- if (!l.head.hasTag(METHODDEF) &&
- (TreeInfo.flags(l.head) & STATIC) != 0) {
- scan(l.head);
+ // process all the static initializers
+ for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+ if (!l.head.hasTag(METHODDEF) &&
+ (TreeInfo.flags(l.head) & STATIC) != 0) {
+ scan(l.head);
+ }
}
- }
- // define all the instance fields
- for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
- if (l.head.hasTag(VARDEF)) {
- JCVariableDecl def = (JCVariableDecl)l.head;
- if ((def.mods.flags & STATIC) == 0) {
- VarSymbol sym = def.sym;
- if (trackable(sym)) {
- newVar(def);
+ // define all the instance fields
+ for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+ if (l.head.hasTag(VARDEF)) {
+ JCVariableDecl def = (JCVariableDecl)l.head;
+ if ((def.mods.flags & STATIC) == 0) {
+ VarSymbol sym = def.sym;
+ if (trackable(sym)) {
+ newVar(def);
+ }
}
}
}
- }
-
- // process all the instance initializers
- for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
- if (!l.head.hasTag(METHODDEF) &&
- (TreeInfo.flags(l.head) & STATIC) == 0) {
- scan(l.head);
+ // process all the instance initializers
+ for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+ if (!l.head.hasTag(METHODDEF) &&
+ (TreeInfo.flags(l.head) & STATIC) == 0) {
+ scan(l.head);
+ }
}
- }
- // process all the methods
- for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
- if (l.head.hasTag(METHODDEF)) {
- scan(l.head);
+ // process all the methods
+ for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
+ if (l.head.hasTag(METHODDEF)) {
+ scan(l.head);
+ }
}
+ } finally {
+ pendingExits = pendingExitsPrev;
+ nextadr = nextadrPrev;
+ firstadr = firstadrPrev;
+ classDef = classDefPrev;
}
} finally {
- pendingExits = pendingExitsPrev;
- nextadr = nextadrPrev;
- firstadr = firstadrPrev;
- classDef = classDefPrev;
+ lint = lintPrev;
}
}
- @Override
public void visitMethodDef(JCMethodDecl tree) {
if (tree.body == null) {
return;
}
- /* Ignore synthetic methods, except for translated lambda methods.
+
+ /* MemberEnter can generate synthetic methods ignore them
*/
- if ((tree.sym.flags() & (SYNTHETIC | LAMBDA_METHOD)) == SYNTHETIC) {
+ if ((tree.sym.flags() & SYNTHETIC) != 0) {
return;
}
- final Bits initsPrev = new Bits(inits);
- final Bits uninitsPrev = new Bits(uninits);
- int nextadrPrev = nextadr;
- int firstadrPrev = firstadr;
- int returnadrPrev = returnadr;
-
- Assert.check(pendingExits.isEmpty());
- boolean lastInitialConstructor = isInitialConstructor;
+ Lint lintPrev = lint;
+ lint = lint.augment(tree.sym);
try {
- isInitialConstructor = TreeInfo.isInitialConstructor(tree);
-
- if (!isInitialConstructor) {
- firstadr = nextadr;
+ if (tree.body == null) {
+ return;
}
- for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
- JCVariableDecl def = l.head;
- scan(def);
- Assert.check((def.sym.flags() & PARAMETER) != 0, "Method parameter without PARAMETER flag");
- /* If we are executing the code from Gen, then there can be
- * synthetic or mandated variables, ignore them.
- */
- initParam(def);
+ /* Ignore synthetic methods, except for translated lambda methods.
+ */
+ if ((tree.sym.flags() & (SYNTHETIC | LAMBDA_METHOD)) == SYNTHETIC) {
+ return;
}
- // else we are in an instance initializer block;
- // leave caught unchanged.
- scan(tree.body);
- if (isInitialConstructor) {
- boolean isSynthesized = (tree.sym.flags() &
- GENERATEDCONSTR) != 0;
- for (int i = firstadr; i < nextadr; i++) {
- JCVariableDecl vardecl = vardecls[i];
- VarSymbol var = vardecl.sym;
- if (var.owner == classDef.sym) {
- // choose the diagnostic position based on whether
- // the ctor is default(synthesized) or not
- if (isSynthesized) {
- checkInit(TreeInfo.diagnosticPositionFor(var, vardecl),
- var, "var.not.initialized.in.default.constructor");
- } else {
- checkInit(TreeInfo.diagEndPos(tree.body), var);
- }
- }
+ final Bits initsPrev = new Bits(inits);
+ final Bits uninitsPrev = new Bits(uninits);
+ int nextadrPrev = nextadr;
+ int firstadrPrev = firstadr;
+ int returnadrPrev = returnadr;
+
+ Assert.check(pendingExits.isEmpty());
+ boolean lastInitialConstructor = isInitialConstructor;
+ try {
+ isInitialConstructor = TreeInfo.isInitialConstructor(tree);
+
+ if (!isInitialConstructor) {
+ firstadr = nextadr;
}
- }
- List<P> exits = pendingExits.toList();
- pendingExits = new ListBuffer<>();
- while (exits.nonEmpty()) {
- P exit = exits.head;
- exits = exits.tail;
- Assert.check(exit.tree.hasTag(RETURN), exit.tree);
+ for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
+ JCVariableDecl def = l.head;
+ scan(def);
+ Assert.check((def.sym.flags() & PARAMETER) != 0, "Method parameter without PARAMETER flag");
+ /* If we are executing the code from Gen, then there can be
+ * synthetic or mandated variables, ignore them.
+ */
+ initParam(def);
+ }
+ // else we are in an instance initializer block;
+ // leave caught unchanged.
+ scan(tree.body);
+
if (isInitialConstructor) {
- assignToInits(exit.tree, exit.exit_inits);
+ boolean isSynthesized = (tree.sym.flags() &
+ GENERATEDCONSTR) != 0;
for (int i = firstadr; i < nextadr; i++) {
- checkInit(exit.tree.pos(), vardecls[i].sym);
+ JCVariableDecl vardecl = vardecls[i];
+ VarSymbol var = vardecl.sym;
+ if (var.owner == classDef.sym) {
+ // choose the diagnostic position based on whether
+ // the ctor is default(synthesized) or not
+ if (isSynthesized) {
+ checkInit(TreeInfo.diagnosticPositionFor(var, vardecl),
+ var, "var.not.initialized.in.default.constructor");
+ } else {
+ checkInit(TreeInfo.diagEndPos(tree.body), var);
+ }
+ }
+ }
+ }
+ List<AssignPendingExit> exits = pendingExits.toList();
+ pendingExits = new ListBuffer<>();
+ while (exits.nonEmpty()) {
+ AssignPendingExit exit = exits.head;
+ exits = exits.tail;
+ Assert.check(exit.tree.hasTag(RETURN), exit.tree);
+ if (isInitialConstructor) {
+ inits.assign(exit.exit_inits);
+ for (int i = firstadr; i < nextadr; i++) {
+ checkInit(exit.tree.pos(), vardecls[i].sym);
+ }
}
}
+ } finally {
+ inits.assign(initsPrev);
+ uninits.assign(uninitsPrev);
+ nextadr = nextadrPrev;
+ firstadr = firstadrPrev;
+ returnadr = returnadrPrev;
+ isInitialConstructor = lastInitialConstructor;
}
} finally {
- assignToInits(tree, initsPrev);
- uninits.assign(uninitsPrev);
- nextadr = nextadrPrev;
- firstadr = firstadrPrev;
- returnadr = returnadrPrev;
- isInitialConstructor = lastInitialConstructor;
+ lint = lintPrev;
}
}
protected void initParam(JCVariableDecl def) {
inits.incl(def.sym.adr);
uninits.excl(def.sym.adr);
- }
+ }
public void visitVarDef(JCVariableDecl tree) {
- boolean track = trackable(tree.sym);
- if (track && tree.sym.owner.kind == MTH) {
- newVar(tree);
- }
- if (tree.init != null) {
- scanExpr(tree.init);
- if (track) {
- letInit(tree.pos(), tree.sym);
+ Lint lintPrev = lint;
+ lint = lint.augment(tree.sym);
+ try{
+ boolean track = trackable(tree.sym);
+ if (track && tree.sym.owner.kind == MTH) {
+ newVar(tree);
+ }
+ if (tree.init != null) {
+ scanExpr(tree.init);
+ if (track) {
+ letInit(tree.pos(), tree.sym);
+ }
}
+ } finally {
+ lint = lintPrev;
}
}
@@ -1844,18 +1884,14 @@ public class Flow {
nextadr = nextadrPrev;
}
- int getLogNumberOfErrors() {
- return 0;
- }
-
public void visitDoLoop(JCDoWhileLoop tree) {
- ListBuffer<P> prevPendingExits = pendingExits;
+ ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
FlowKind prevFlowKind = flowKind;
flowKind = FlowKind.NORMAL;
final Bits initsSkip = new Bits(true);
final Bits uninitsSkip = new Bits(true);
- pendingExits = new ListBuffer<P>();
- int prevErrors = getLogNumberOfErrors();
+ pendingExits = new ListBuffer<>();
+ int prevErrors = log.nerrors;
do {
final Bits uninitsEntry = new Bits(uninits);
uninitsEntry.excludeFrom(nextadr);
@@ -1866,28 +1902,28 @@ public class Flow {
initsSkip.assign(initsWhenFalse);
uninitsSkip.assign(uninitsWhenFalse);
}
- if (getLogNumberOfErrors() != prevErrors ||
+ if (log.nerrors != prevErrors ||
flowKind.isFinal() ||
new Bits(uninitsEntry).diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
break;
- assignToInits(tree.cond, initsWhenTrue);
+ inits.assign(initsWhenTrue);
uninits.assign(uninitsEntry.andSet(uninitsWhenTrue));
flowKind = FlowKind.SPECULATIVE_LOOP;
} while (true);
flowKind = prevFlowKind;
- assignToInits(tree, initsSkip);
+ inits.assign(initsSkip);
uninits.assign(uninitsSkip);
resolveBreaks(tree, prevPendingExits);
}
public void visitWhileLoop(JCWhileLoop tree) {
- ListBuffer<P> prevPendingExits = pendingExits;
+ ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
FlowKind prevFlowKind = flowKind;
flowKind = FlowKind.NORMAL;
final Bits initsSkip = new Bits(true);
final Bits uninitsSkip = new Bits(true);
pendingExits = new ListBuffer<>();
- int prevErrors = getLogNumberOfErrors();
+ int prevErrors = log.nerrors;
final Bits uninitsEntry = new Bits(uninits);
uninitsEntry.excludeFrom(nextadr);
do {
@@ -1896,11 +1932,11 @@ public class Flow {
initsSkip.assign(initsWhenFalse) ;
uninitsSkip.assign(uninitsWhenFalse);
}
- assignToInits(tree, initsWhenTrue);
+ inits.assign(initsWhenTrue);
uninits.assign(uninitsWhenTrue);
scan(tree.body);
resolveContinues(tree);
- if (getLogNumberOfErrors() != prevErrors ||
+ if (log.nerrors != prevErrors ||
flowKind.isFinal() ||
new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1) {
break;
@@ -1911,21 +1947,21 @@ public class Flow {
flowKind = prevFlowKind;
//a variable is DA/DU after the while statement, if it's DA/DU assuming the
//branch is not taken AND if it's DA/DU before any break statement
- assignToInits(tree.body, initsSkip);
+ inits.assign(initsSkip);
uninits.assign(uninitsSkip);
resolveBreaks(tree, prevPendingExits);
}
public void visitForLoop(JCForLoop tree) {
- ListBuffer<P> prevPendingExits = pendingExits;
+ ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
FlowKind prevFlowKind = flowKind;
flowKind = FlowKind.NORMAL;
int nextadrPrev = nextadr;
scan(tree.init);
final Bits initsSkip = new Bits(true);
final Bits uninitsSkip = new Bits(true);
- pendingExits = new ListBuffer<P>();
- int prevErrors = getLogNumberOfErrors();
+ pendingExits = new ListBuffer<>();
+ int prevErrors = log.nerrors;
do {
final Bits uninitsEntry = new Bits(uninits);
uninitsEntry.excludeFrom(nextadr);
@@ -1935,7 +1971,7 @@ public class Flow {
initsSkip.assign(initsWhenFalse);
uninitsSkip.assign(uninitsWhenFalse);
}
- assignToInits(tree.body, initsWhenTrue);
+ inits.assign(initsWhenTrue);
uninits.assign(uninitsWhenTrue);
} else if (!flowKind.isFinal()) {
initsSkip.assign(inits);
@@ -1946,7 +1982,7 @@ public class Flow {
scan(tree.body);
resolveContinues(tree);
scan(tree.step);
- if (getLogNumberOfErrors() != prevErrors ||
+ if (log.nerrors != prevErrors ||
flowKind.isFinal() ||
new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1)
break;
@@ -1956,7 +1992,7 @@ public class Flow {
flowKind = prevFlowKind;
//a variable is DA/DU after a for loop, if it's DA/DU assuming the
//branch is not taken AND if it's DA/DU before any break statement
- assignToInits(tree.body, initsSkip);
+ inits.assign(initsSkip);
uninits.assign(uninitsSkip);
resolveBreaks(tree, prevPendingExits);
nextadr = nextadrPrev;
@@ -1965,7 +2001,7 @@ public class Flow {
public void visitForeachLoop(JCEnhancedForLoop tree) {
visitVarDef(tree.var);
- ListBuffer<P> prevPendingExits = pendingExits;
+ ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
FlowKind prevFlowKind = flowKind;
flowKind = FlowKind.NORMAL;
int nextadrPrev = nextadr;
@@ -1974,14 +2010,14 @@ public class Flow {
final Bits uninitsStart = new Bits(uninits);
letInit(tree.pos(), tree.var.sym);
- pendingExits = new ListBuffer<P>();
- int prevErrors = getLogNumberOfErrors();
+ pendingExits = new ListBuffer<>();
+ int prevErrors = log.nerrors;
do {
final Bits uninitsEntry = new Bits(uninits);
uninitsEntry.excludeFrom(nextadr);
scan(tree.body);
resolveContinues(tree);
- if (getLogNumberOfErrors() != prevErrors ||
+ if (log.nerrors != prevErrors ||
flowKind.isFinal() ||
new Bits(uninitsEntry).diffSet(uninits).nextBit(firstadr) == -1)
break;
@@ -1989,21 +2025,21 @@ public class Flow {
flowKind = FlowKind.SPECULATIVE_LOOP;
} while (true);
flowKind = prevFlowKind;
- assignToInits(tree.body, initsStart);
+ inits.assign(initsStart);
uninits.assign(uninitsStart.andSet(uninits));
resolveBreaks(tree, prevPendingExits);
nextadr = nextadrPrev;
}
public void visitLabelled(JCLabeledStatement tree) {
- ListBuffer<P> prevPendingExits = pendingExits;
- pendingExits = new ListBuffer<P>();
+ ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
+ pendingExits = new ListBuffer<>();
scan(tree.body);
resolveBreaks(tree, prevPendingExits);
}
public void visitSwitch(JCSwitch tree) {
- ListBuffer<P> prevPendingExits = pendingExits;
+ ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<>();
int nextadrPrev = nextadr;
scanExpr(tree.selector);
@@ -2011,7 +2047,7 @@ public class Flow {
final Bits uninitsSwitch = new Bits(uninits);
boolean hasDefault = false;
for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
- assignToInits(l.head, initsSwitch);
+ inits.assign(initsSwitch);
uninits.assign(uninits.andSet(uninitsSwitch));
JCCase c = l.head;
if (c.pat == null) {
@@ -2020,19 +2056,19 @@ public class Flow {
scanExpr(c.pat);
}
if (hasDefault) {
- assignToInits(null, initsSwitch);
+ inits.assign(initsSwitch);
uninits.assign(uninits.andSet(uninitsSwitch));
}
scan(c.stats);
addVars(c.stats, initsSwitch, uninitsSwitch);
if (!hasDefault) {
- assignToInits(l.head.stats.last(), initsSwitch);
+ inits.assign(initsSwitch);
uninits.assign(uninits.andSet(uninitsSwitch));
}
// Warn about fall-through if lint switch fallthrough enabled.
}
if (!hasDefault) {
- andSetInits(null, initsSwitch);
+ inits.andSet(initsSwitch);
}
resolveBreaks(tree, prevPendingExits);
nextadr = nextadrPrev;
@@ -2051,16 +2087,10 @@ public class Flow {
}
}
- boolean isEnabled(Lint.LintCategory lc) {
- return false;
- }
-
- void reportWarning(Lint.LintCategory lc, DiagnosticPosition pos, String key, Object ... args) {}
-
public void visitTry(JCTry tree) {
ListBuffer<JCVariableDecl> resourceVarDecls = new ListBuffer<>();
final Bits uninitsTryPrev = new Bits(uninitsTry);
- ListBuffer<P> prevPendingExits = pendingExits;
+ ListBuffer<AssignPendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<>();
final Bits initsTry = new Bits(inits);
uninitsTry.assign(uninits);
@@ -2083,10 +2113,10 @@ public class Flow {
int nextadrCatch = nextadr;
if (!resourceVarDecls.isEmpty() &&
- isEnabled(Lint.LintCategory.TRY)) {
+ lint.isEnabled(Lint.LintCategory.TRY)) {
for (JCVariableDecl resVar : resourceVarDecls) {
if (unrefdResources.includes(resVar.sym)) {
- reportWarning(Lint.LintCategory.TRY, resVar.pos(),
+ log.warning(Lint.LintCategory.TRY, resVar.pos(),
"try.resource.not.referenced", resVar.sym);
unrefdResources.remove(resVar.sym);
}
@@ -2102,7 +2132,7 @@ public class Flow {
for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
JCVariableDecl param = l.head.param;
- assignToInits(tree.body, initsCatchPrev);
+ inits.assign(initsCatchPrev);
uninits.assign(uninitsCatchPrev);
scan(param);
/* If this is a TWR and we are executing the code from Gen,
@@ -2115,9 +2145,9 @@ public class Flow {
nextadr = nextadrCatch;
}
if (tree.finalizer != null) {
- assignToInits(tree.finalizer, initsTry);
+ inits.assign(initsTry);
uninits.assign(uninitsTry);
- ListBuffer<P> exits = pendingExits;
+ ListBuffer<AssignPendingExit> exits = pendingExits;
pendingExits = prevPendingExits;
scan(tree.finalizer);
if (!tree.finallyCanCompleteNormally) {
@@ -2127,19 +2157,19 @@ public class Flow {
// FIX: this doesn't preserve source order of exits in catch
// versus finally!
while (exits.nonEmpty()) {
- P exit = exits.next();
+ AssignPendingExit exit = exits.next();
if (exit.exit_inits != null) {
exit.exit_inits.orSet(inits);
exit.exit_uninits.andSet(uninits);
}
pendingExits.append(exit);
}
- orSetInits(tree, initsEnd);
+ inits.orSet(initsEnd);
}
} else {
- assignToInits(tree, initsEnd);
+ inits.assign(initsEnd);
uninits.assign(uninitsEnd);
- ListBuffer<P> exits = pendingExits;
+ ListBuffer<AssignPendingExit> exits = pendingExits;
pendingExits = prevPendingExits;
while (exits.nonEmpty()) pendingExits.append(exits.next());
}
@@ -2150,7 +2180,7 @@ public class Flow {
scanCond(tree.cond);
final Bits initsBeforeElse = new Bits(initsWhenFalse);
final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse);
- assignToInits(tree.cond, initsWhenTrue);
+ inits.assign(initsWhenTrue);
uninits.assign(uninitsWhenTrue);
if (tree.truepart.type.hasTag(BOOLEAN) &&
tree.falsepart.type.hasTag(BOOLEAN)) {
@@ -2163,7 +2193,7 @@ public class Flow {
final Bits initsAfterThenWhenFalse = new Bits(initsWhenFalse);
final Bits uninitsAfterThenWhenTrue = new Bits(uninitsWhenTrue);
final Bits uninitsAfterThenWhenFalse = new Bits(uninitsWhenFalse);
- assignToInits(tree.truepart, initsBeforeElse);
+ inits.assign(initsBeforeElse);
uninits.assign(uninitsBeforeElse);
scanCond(tree.falsepart);
initsWhenTrue.andSet(initsAfterThenWhenTrue);
@@ -2174,10 +2204,10 @@ public class Flow {
scanExpr(tree.truepart);
final Bits initsAfterThen = new Bits(inits);
final Bits uninitsAfterThen = new Bits(uninits);
- assignToInits(tree.truepart, initsBeforeElse);
+ inits.assign(initsBeforeElse);
uninits.assign(uninitsBeforeElse);
scanExpr(tree.falsepart);
- andSetInits(tree.falsepart, initsAfterThen);
+ inits.andSet(initsAfterThen);
uninits.andSet(uninitsAfterThen);
}
}
@@ -2186,46 +2216,42 @@ public class Flow {
scanCond(tree.cond);
final Bits initsBeforeElse = new Bits(initsWhenFalse);
final Bits uninitsBeforeElse = new Bits(uninitsWhenFalse);
- assignToInits(tree.cond, initsWhenTrue);
+ inits.assign(initsWhenTrue);
uninits.assign(uninitsWhenTrue);
scan(tree.thenpart);
if (tree.elsepart != null) {
final Bits initsAfterThen = new Bits(inits);
final Bits uninitsAfterThen = new Bits(uninits);
- assignToInits(tree.thenpart, initsBeforeElse);
+ inits.assign(initsBeforeElse);
uninits.assign(uninitsBeforeElse);
scan(tree.elsepart);
- andSetInits(tree.elsepart, initsAfterThen);
+ inits.andSet(initsAfterThen);
uninits.andSet(uninitsAfterThen);
} else {
- andSetInits(tree.thenpart, initsBeforeElse);
+ inits.andSet(initsBeforeElse);
uninits.andSet(uninitsBeforeElse);
}
}
- protected P createNewPendingExit(JCTree tree, Bits inits, Bits uninits) {
- return null;
- }
-
@Override
public void visitBreak(JCBreak tree) {
- recordExit(tree, createNewPendingExit(tree, inits, uninits));
+ recordExit(new AssignPendingExit(tree, inits, uninits));
}
@Override
public void visitContinue(JCContinue tree) {
- recordExit(tree, createNewPendingExit(tree, inits, uninits));
+ recordExit(new AssignPendingExit(tree, inits, uninits));
}
@Override
public void visitReturn(JCReturn tree) {
scanExpr(tree.expr);
- recordExit(tree, createNewPendingExit(tree, inits, uninits));
+ recordExit(new AssignPendingExit(tree, inits, uninits));
}
public void visitThrow(JCThrow tree) {
scanExpr(tree.expr);
- markDead(tree.expr);
+ markDead();
}
public void visitApply(JCMethodInvocation tree) {
@@ -2244,10 +2270,10 @@ public class Flow {
final Bits prevUninits = new Bits(uninits);
final Bits prevInits = new Bits(inits);
int returnadrPrev = returnadr;
- ListBuffer<P> prevPending = pendingExits;
+ ListBuffer<AssignPendingExit> prevPending = pendingExits;
try {
returnadr = nextadr;
- pendingExits = new ListBuffer<P>();
+ pendingExits = new ListBuffer<>();
for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
JCVariableDecl def = l.head;
scan(def);
@@ -2263,7 +2289,7 @@ public class Flow {
finally {
returnadr = returnadrPrev;
uninits.assign(prevUninits);
- assignToInits(tree, prevInits);
+ inits.assign(prevInits);
pendingExits = prevPending;
}
}
@@ -2279,11 +2305,11 @@ public class Flow {
scanCond(tree.cond);
uninitsExit.andSet(uninitsWhenTrue);
if (tree.detail != null) {
- assignToInits(tree, initsWhenFalse);
+ inits.assign(initsWhenFalse);
uninits.assign(uninitsWhenFalse);
scanExpr(tree.detail);
}
- assignToInits(tree, initsExit);
+ inits.assign(initsExit);
uninits.assign(uninitsExit);
}
@@ -2351,7 +2377,7 @@ public class Flow {
scanCond(tree.lhs);
final Bits initsWhenFalseLeft = new Bits(initsWhenFalse);
final Bits uninitsWhenFalseLeft = new Bits(uninitsWhenFalse);
- assignToInits(tree.lhs, initsWhenTrue);
+ inits.assign(initsWhenTrue);
uninits.assign(uninitsWhenTrue);
scanCond(tree.rhs);
initsWhenFalse.andSet(initsWhenFalseLeft);
@@ -2361,7 +2387,7 @@ public class Flow {
scanCond(tree.lhs);
final Bits initsWhenTrueLeft = new Bits(initsWhenTrue);
final Bits uninitsWhenTrueLeft = new Bits(uninitsWhenTrue);
- assignToInits(tree.lhs, initsWhenFalse);
+ inits.assign(initsWhenFalse);
uninits.assign(uninitsWhenFalse);
scanCond(tree.rhs);
initsWhenTrue.andSet(initsWhenTrueLeft);
@@ -2436,136 +2462,6 @@ public class Flow {
}
}
- public class AssignAnalyzer extends AbstractAssignAnalyzer<AssignAnalyzer.AssignPendingExit> {
-
- public class AssignPendingExit extends AbstractAssignAnalyzer<AssignPendingExit>.AbstractAssignPendingExit {
-
- public AssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) {
- super(tree, inits, uninits);
- }
- }
-
- @Override
- protected AssignPendingExit createNewPendingExit(JCTree tree,
- Bits inits, Bits uninits) {
- return new AssignPendingExit(tree, inits, uninits);
- }
-
- /** Record an initialization of a trackable variable.
- */
- @Override
- void letInit(DiagnosticPosition pos, VarSymbol sym) {
- if (sym.adr >= firstadr && trackable(sym)) {
- if ((sym.flags() & EFFECTIVELY_FINAL) != 0) {
- if (!uninits.isMember(sym.adr)) {
- //assignment targeting an effectively final variable
- //makes the variable lose its status of effectively final
- //if the variable is _not_ definitively unassigned
- sym.flags_field &= ~EFFECTIVELY_FINAL;
- } else {
- uninit(sym);
- }
- }
- else if ((sym.flags() & FINAL) != 0) {
- if ((sym.flags() & PARAMETER) != 0) {
- if ((sym.flags() & UNION) != 0) { //multi-catch parameter
- log.error(pos, "multicatch.parameter.may.not.be.assigned", sym);
- }
- else {
- log.error(pos, "final.parameter.may.not.be.assigned",
- sym);
- }
- } else if (!uninits.isMember(sym.adr)) {
- log.error(pos, flowKind.errKey, sym);
- } else {
- uninit(sym);
- }
- }
- inits.incl(sym.adr);
- } else if ((sym.flags() & FINAL) != 0) {
- log.error(pos, "var.might.already.be.assigned", sym);
- }
- }
-
- @Override
- void checkInit(DiagnosticPosition pos, VarSymbol sym, String errkey) {
- if ((sym.adr >= firstadr || sym.owner.kind != TYP) &&
- trackable(sym) &&
- !inits.isMember(sym.adr)) {
- log.error(pos, errkey, sym);
- inits.incl(sym.adr);
- }
- }
-
- @Override
- void reportWarning(Lint.LintCategory lc, DiagnosticPosition pos,
- String key, Object ... args) {
- log.warning(lc, pos, key, args);
- }
-
- @Override
- int getLogNumberOfErrors() {
- return log.nerrors;
- }
-
- @Override
- boolean isEnabled(Lint.LintCategory lc) {
- return lint.isEnabled(lc);
- }
-
- @Override
- public void visitClassDef(JCClassDecl tree) {
- if (tree.sym == null) {
- return;
- }
-
- Lint lintPrev = lint;
- lint = lint.augment(tree.sym);
- try {
- super.visitClassDef(tree);
- } finally {
- lint = lintPrev;
- }
- }
-
- @Override
- public void visitMethodDef(JCMethodDecl tree) {
- if (tree.body == null) {
- return;
- }
-
- /* MemberEnter can generate synthetic methods ignore them
- */
- if ((tree.sym.flags() & SYNTHETIC) != 0) {
- return;
- }
-
- Lint lintPrev = lint;
- lint = lint.augment(tree.sym);
- try {
- super.visitMethodDef(tree);
- } finally {
- lint = lintPrev;
- }
- }
-
- @Override
- public void visitVarDef(JCVariableDecl tree) {
- if (tree.init == null) {
- super.visitVarDef(tree);
- } else {
- Lint lintPrev = lint;
- lint = lint.augment(tree.sym);
- try{
- super.visitVarDef(tree);
- } finally {
- lint = lintPrev;
- }
- }
- }
-
- }
-
/**
* This pass implements the last step of the dataflow analysis, namely
* the effectively-final analysis check. This checks that every local variable
@@ -2578,7 +2474,7 @@ public class Flow {
JCTree currentTree; //local class or lambda
@Override
- void markDead(JCTree tree) {
+ void markDead() {
//do nothing
}
@@ -2715,7 +2611,7 @@ public class Flow {
try {
attrEnv = env;
Flow.this.make = make;
- pendingExits = new ListBuffer<PendingExit>();
+ pendingExits = new ListBuffer<>();
scan(tree);
} finally {
pendingExits = null;
diff --git a/src/share/classes/com/sun/tools/javac/comp/Infer.java b/src/share/classes/com/sun/tools/javac/comp/Infer.java
index 9d7a01d8..c88386ed 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java
@@ -315,11 +315,9 @@ public class Infer {
for (Type aLowerBound : from.getBounds(InferenceBound.LOWER)) {
for (Type anotherLowerBound : from.getBounds(InferenceBound.LOWER)) {
if (aLowerBound != anotherLowerBound &&
- commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) {
- /* self comment check if any lower bound may be and undetVar,
- * in that case the result of this call may be a false positive.
- * Should this be restricted to non free types?
- */
+ !inferenceContext.free(aLowerBound) &&
+ !inferenceContext.free(anotherLowerBound) &&
+ commonSuperWithDiffParameterization(aLowerBound, anotherLowerBound)) {
return generateReferenceToTargetConstraint(tree, from, to,
resultInfo, inferenceContext);
}
@@ -375,7 +373,7 @@ public class Infer {
List<Type> upperBounds = uv.getBounds(InferenceBound.UPPER);
if (Type.containsAny(upperBounds, vars)) {
TypeSymbol fresh_tvar = new TypeVariableSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner);
- fresh_tvar.type = new TypeVar(fresh_tvar, types.makeCompoundType(uv.getBounds(InferenceBound.UPPER)), null);
+ fresh_tvar.type = new TypeVar(fresh_tvar, types.makeIntersectionType(uv.getBounds(InferenceBound.UPPER)), null);
todo.append(uv);
uv.inst = fresh_tvar.type;
} else if (upperBounds.nonEmpty()) {
diff --git a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
index 10e9a127..1253f872 100644
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
+++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
@@ -265,7 +265,7 @@ public class LambdaToMethod extends TreeTranslator {
@Override
public void visitLambda(JCLambda tree) {
LambdaTranslationContext localContext = (LambdaTranslationContext)context;
- MethodSymbol sym = (MethodSymbol)localContext.translatedSym;
+ MethodSymbol sym = localContext.translatedSym;
MethodType lambdaType = (MethodType) sym.type;
{
@@ -1179,12 +1179,14 @@ public class LambdaToMethod extends TreeTranslator {
@Override
public void visitClassDef(JCClassDecl tree) {
List<Frame> prevStack = frameStack;
+ int prevLambdaCount = lambdaCount;
SyntheticMethodNameCounter prevSyntheticMethodNameCounts =
syntheticMethodNameCounts;
Map<ClassSymbol, Symbol> prevClinits = clinits;
DiagnosticSource prevSource = log.currentSource();
try {
log.useSource(tree.sym.sourcefile);
+ lambdaCount = 0;
syntheticMethodNameCounts = new SyntheticMethodNameCounter();
prevClinits = new HashMap<ClassSymbol, Symbol>();
if (tree.sym.owner.kind == MTH) {
@@ -1211,6 +1213,7 @@ public class LambdaToMethod extends TreeTranslator {
finally {
log.useSource(prevSource.getFile());
frameStack = prevStack;
+ lambdaCount = prevLambdaCount;
syntheticMethodNameCounts = prevSyntheticMethodNameCounts;
clinits = prevClinits;
}
@@ -1755,7 +1758,7 @@ public class LambdaToMethod extends TreeTranslator {
Map<LambdaSymbolKind, Map<Symbol, Symbol>> translatedSymbols;
/** the synthetic symbol for the method hoisting the translated lambda */
- Symbol translatedSym;
+ MethodSymbol translatedSym;
List<JCVariableDecl> syntheticParams;
@@ -1883,7 +1886,7 @@ public class LambdaToMethod extends TreeTranslator {
* Translate a symbol of a given kind into something suitable for the
* synthetic lambda body
*/
- Symbol translate(Name name, final Symbol sym, LambdaSymbolKind skind) {
+ Symbol translate(final Symbol sym, LambdaSymbolKind skind) {
Symbol ret;
switch (skind) {
case CAPTURED_THIS:
@@ -1891,7 +1894,7 @@ public class LambdaToMethod extends TreeTranslator {
break;
case TYPE_VAR:
// Just erase the type var
- ret = new VarSymbol(sym.flags(), name,
+ ret = new VarSymbol(sym.flags(), sym.name,
types.erasure(sym.type), sym.owner);
/* this information should also be kept for LVT generation at Gen
@@ -1900,7 +1903,7 @@ public class LambdaToMethod extends TreeTranslator {
((VarSymbol)ret).pos = ((VarSymbol)sym).pos;
break;
case CAPTURED_VAR:
- ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) {
+ ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, sym.name, types.erasure(sym.type), translatedSym) {
@Override
public Symbol baseSymbol() {
//keep mapping with original captured symbol
@@ -1909,16 +1912,16 @@ public class LambdaToMethod extends TreeTranslator {
};
break;
case LOCAL_VAR:
- ret = new VarSymbol(sym.flags() & FINAL, name, sym.type, translatedSym);
+ ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym);
((VarSymbol) ret).pos = ((VarSymbol) sym).pos;
break;
case PARAM:
- ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, name, types.erasure(sym.type), translatedSym);
+ ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, sym.name, types.erasure(sym.type), translatedSym);
((VarSymbol) ret).pos = ((VarSymbol) sym).pos;
break;
default:
- ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym);
- ((VarSymbol) ret).pos = ((VarSymbol) sym).pos;
+ Assert.error(skind.name());
+ throw new AssertionError();
}
if (ret != sym) {
ret.setDeclarationAttributes(sym.getRawAttributes());
@@ -1929,27 +1932,8 @@ public class LambdaToMethod extends TreeTranslator {
void addSymbol(Symbol sym, LambdaSymbolKind skind) {
Map<Symbol, Symbol> transMap = getSymbolMap(skind);
- Name preferredName;
- switch (skind) {
- case CAPTURED_THIS:
- preferredName = names.fromString("encl$" + transMap.size());
- break;
- case CAPTURED_VAR:
- preferredName = names.fromString("cap$" + transMap.size());
- break;
- case LOCAL_VAR:
- preferredName = sym.name;
- break;
- case PARAM:
- preferredName = sym.name;
- break;
- case TYPE_VAR:
- preferredName = sym.name;
- break;
- default: throw new AssertionError();
- }
if (!transMap.containsKey(sym)) {
- transMap.put(sym, translate(preferredName, sym, skind));
+ transMap.put(sym, translate(sym, skind));
}
}
@@ -1997,6 +1981,7 @@ public class LambdaToMethod extends TreeTranslator {
//compute synthetic params
ListBuffer<JCVariableDecl> params = new ListBuffer<>();
+ ListBuffer<VarSymbol> parameterSymbols = new ListBuffer<>();
// The signature of the method is augmented with the following
// synthetic parameters:
@@ -2005,19 +1990,16 @@ public class LambdaToMethod extends TreeTranslator {
// 2) enclosing locals captured by the lambda expression
for (Symbol thisSym : getSymbolMap(CAPTURED_VAR).values()) {
params.append(make.VarDef((VarSymbol) thisSym, null));
- }
- if (methodReferenceReceiver != null) {
- params.append(make.VarDef(
- make.Modifiers(PARAMETER|FINAL),
- names.fromString("$rcvr$"),
- make.Type(methodReferenceReceiver.type),
- null));
+ parameterSymbols.append((VarSymbol) thisSym);
}
for (Symbol thisSym : getSymbolMap(PARAM).values()) {
params.append(make.VarDef((VarSymbol) thisSym, null));
+ parameterSymbols.append((VarSymbol) thisSym);
}
syntheticParams = params.toList();
+ translatedSym.params = parameterSymbols.toList();
+
// Compute and set the lambda name
translatedSym.name = isSerializable()
? serializedLambdaName()
diff --git a/src/share/classes/com/sun/tools/javac/comp/Lower.java b/src/share/classes/com/sun/tools/javac/comp/Lower.java
index 21e8f823..717a3160 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java
@@ -2540,7 +2540,7 @@ public class Lower extends TreeTranslator {
currentMethodSym = currentMethodSymPrev;
// Return empty block {} as a placeholder for an inner class.
- result = make_at(tree.pos()).Block(0, List.<JCStatement>nil());
+ result = make_at(tree.pos()).Block(SYNTHETIC, List.<JCStatement>nil());
}
/** Translate an enum class. */
diff --git a/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
index 87a29320..7b3d3e26 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
@@ -271,7 +271,7 @@ public class Resolve {
* the one of its outer environment
*/
protected static boolean isStatic(Env<AttrContext> env) {
- return env.info.staticLevel > env.outer.info.staticLevel;
+ return env.outer != null && env.info.staticLevel > env.outer.info.staticLevel;
}
/** An environment is an "initializer" if it is a constructor or
@@ -717,7 +717,8 @@ public class Resolve {
Warner warn) {
//should we expand formals?
boolean useVarargs = deferredAttrContext.phase.isVarargsRequired();
- List<JCExpression> trees = TreeInfo.args(env.tree);
+ JCTree callTree = treeForDiagnostics(env);
+ List<JCExpression> trees = TreeInfo.args(callTree);
//inference context used during this method check
InferenceContext inferenceContext = deferredAttrContext.inferenceContext;
@@ -726,7 +727,7 @@ public class Resolve {
if (varargsFormal == null &&
argtypes.size() != formals.size()) {
- reportMC(env.tree, MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
+ reportMC(callTree, MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
}
while (argtypes.nonEmpty() && formals.head != varargsFormal) {
@@ -738,7 +739,7 @@ public class Resolve {
}
if (formals.head != varargsFormal) {
- reportMC(env.tree, MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
+ reportMC(callTree, MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args
}
if (useVarargs) {
@@ -754,6 +755,11 @@ public class Resolve {
}
}
+ // where
+ private JCTree treeForDiagnostics(Env<AttrContext> env) {
+ return env.info.preferredTreeForDiagnostics != null ? env.info.preferredTreeForDiagnostics : env.tree;
+ }
+
/**
* Does the actual argument conforms to the corresponding formal?
*/
@@ -836,20 +842,19 @@ public class Resolve {
List<Type> formals,
Warner warn) {
super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn);
- //should we expand formals?
+ // should we check varargs element type accessibility?
if (deferredAttrContext.phase.isVarargsRequired()) {
- Type typeToCheck = null;
- if (!checkVarargsAccessAfterResolution) {
- typeToCheck = types.elemtype(formals.last());
- } else if (deferredAttrContext.mode == AttrMode.CHECK) {
- typeToCheck = types.erasure(types.elemtype(formals.last()));
- }
- if (typeToCheck != null) {
- varargsAccessible(env, typeToCheck, deferredAttrContext.inferenceContext);
+ if (deferredAttrContext.mode == AttrMode.CHECK || !checkVarargsAccessAfterResolution) {
+ varargsAccessible(env, types.elemtype(formals.last()), deferredAttrContext.inferenceContext);
}
}
}
+ /**
+ * Test that the runtime array element type corresponding to 't' is accessible. 't' should be the
+ * varargs element type of either the method invocation type signature (after inference completes)
+ * or the method declaration signature (before inference completes).
+ */
private void varargsAccessible(final Env<AttrContext> env, final Type t, final InferenceContext inferenceContext) {
if (inferenceContext.free(t)) {
inferenceContext.addFreeTypeListener(List.of(t), new FreeTypeListener() {
@@ -859,7 +864,7 @@ public class Resolve {
}
});
} else {
- if (!isAccessible(env, t)) {
+ if (!isAccessible(env, types.erasure(t))) {
Symbol location = env.enclClass.sym;
reportMC(env.tree, MethodCheckDiag.INACCESSIBLE_VARARGS, inferenceContext, t, Kinds.kindName(location), location);
}
@@ -1829,17 +1834,23 @@ public class Resolve {
boolean staticOnly = false;
while (env1.outer != null) {
if (isStatic(env1)) staticOnly = true;
- sym = findMethod(
- env1, env1.enclClass.sym.type, name, argtypes, typeargtypes,
- allowBoxing, useVarargs, false);
- if (sym.exists()) {
- if (staticOnly &&
- sym.kind == MTH &&
- sym.owner.kind == TYP &&
- (sym.flags() & STATIC) == 0) return new StaticError(sym);
- else return sym;
- } else if (sym.kind < bestSoFar.kind) {
- bestSoFar = sym;
+ Assert.check(env1.info.preferredTreeForDiagnostics == null);
+ env1.info.preferredTreeForDiagnostics = env.tree;
+ try {
+ sym = findMethod(
+ env1, env1.enclClass.sym.type, name, argtypes, typeargtypes,
+ allowBoxing, useVarargs, false);
+ if (sym.exists()) {
+ if (staticOnly &&
+ sym.kind == MTH &&
+ sym.owner.kind == TYP &&
+ (sym.flags() & STATIC) == 0) return new StaticError(sym);
+ else return sym;
+ } else if (sym.kind < bestSoFar.kind) {
+ bestSoFar = sym;
+ }
+ } finally {
+ env1.info.preferredTreeForDiagnostics = null;
}
if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true;
env1 = env1.outer;
@@ -4087,7 +4098,7 @@ public class Resolve {
s : new MethodSymbol(
s.flags(),
s.name,
- types.createMethodTypeWithThrown(mt, allThrown),
+ types.createMethodTypeWithThrown(s.type, allThrown),
s.owner);
}
}
@@ -4215,7 +4226,11 @@ public class Resolve {
DiagnosticPosition preferedPos, DiagnosticSource preferredSource,
DiagnosticType preferredKind, JCDiagnostic d) {
JCDiagnostic cause = (JCDiagnostic)d.getArgs()[0];
- return diags.create(preferredKind, preferredSource, d.getDiagnosticPosition(),
+ DiagnosticPosition pos = d.getDiagnosticPosition();
+ if (pos == null) {
+ pos = preferedPos;
+ }
+ return diags.create(preferredKind, preferredSource, pos,
"prob.found.req", cause);
}
});
diff --git a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java
index b7f0537e..ad00b788 100644
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java
+++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java
@@ -750,7 +750,7 @@ public class TransTypes extends TreeTranslator {
Type originalTarget = tree.type;
tree.type = erasure(tree.type);
tree.expr = translate(tree.expr, tree.type);
- if (originalTarget.isCompound()) {
+ if (originalTarget.isIntersection()) {
Type.IntersectionClassType ict = (Type.IntersectionClassType)originalTarget;
for (Type c : ict.getExplicitComponents()) {
Type ec = erasure(c);
diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
index 84f2600a..40248923 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1779,15 +1779,17 @@ public class ClassReader {
// The method wasn't found: emit a warning and recover
JavaFileObject prevSource = log.useSource(requestingOwner.classfile);
try {
- if (failure == null) {
- log.warning("annotation.method.not.found",
- container,
- name);
- } else {
- log.warning("annotation.method.not.found.reason",
- container,
- name,
- failure.getDetailValue());//diagnostic, if present
+ if (lintClassfile) {
+ if (failure == null) {
+ log.warning("annotation.method.not.found",
+ container,
+ name);
+ } else {
+ log.warning("annotation.method.not.found.reason",
+ container,
+ name,
+ failure.getDetailValue()); //diagnostic, if present
+ }
}
} finally {
log.useSource(prevSource);
diff --git a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
index 83d43afc..eecd6807 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1027,6 +1027,7 @@ public class ClassWriter extends ClassFile {
l.nonEmpty();
l = l.tail) {
ClassSymbol inner = l.head;
+ inner.markAbstractIfNeeded(types);
char flags = (char) adjustFlags(inner.flags_field);
if ((flags & INTERFACE) != 0) flags |= ABSTRACT; // Interfaces are always ABSTRACT
if (inner.name.isEmpty()) flags &= ~FINAL; // Anonymous class: unset FINAL flag
@@ -1186,7 +1187,7 @@ public class ClassWriter extends ClassFile {
Assert.check(r.start_pc >= 0
&& r.start_pc <= code.cp);
databuf.appendChar(r.start_pc);
- Assert.check(r.length >= 0
+ Assert.check(r.length > 0
&& (r.start_pc + r.length) <= code.cp);
databuf.appendChar(r.length);
VarSymbol sym = var.sym;
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Code.java b/src/share/classes/com/sun/tools/javac/jvm/Code.java
index b2a29e79..738c5a1d 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -182,8 +182,6 @@ public class Code {
final MethodSymbol meth;
- final LVTRanges lvtRanges;
-
/** Construct a code object, given the settings of the fatcode,
* debugging info switches and the CharacterRangeTable.
*/
@@ -196,8 +194,7 @@ public class Code {
CRTable crt,
Symtab syms,
Types types,
- Pool pool,
- LVTRanges lvtRanges) {
+ Pool pool) {
this.meth = meth;
this.fatcode = fatcode;
this.lineMap = lineMap;
@@ -219,7 +216,6 @@ public class Code {
state = new State();
lvar = new LocalVar[20];
this.pool = pool;
- this.lvtRanges = lvtRanges;
}
@@ -1193,7 +1189,9 @@ public class Code {
public int entryPoint(State state) {
int pc = curCP();
alive = true;
- this.state = state.dup();
+ State newState = state.dup();
+ setDefined(newState.defined);
+ this.state = newState;
Assert.check(state.stacksize <= max_stack);
if (debugCode) System.err.println("entry point " + state);
pendingStackMap = needStackMap;
@@ -1206,7 +1204,9 @@ public class Code {
public int entryPoint(State state, Type pushed) {
int pc = curCP();
alive = true;
- this.state = state.dup();
+ State newState = state.dup();
+ setDefined(newState.defined);
+ this.state = newState;
Assert.check(state.stacksize <= max_stack);
this.state.push(pushed);
if (debugCode) System.err.println("entry point " + state);
@@ -2008,27 +2008,6 @@ public class Code {
state.defined.excl(adr);
}
-
- public void closeAliveRanges(JCTree tree) {
- closeAliveRanges(tree, cp);
- }
-
- public void closeAliveRanges(JCTree tree, int closingCP) {
- List<VarSymbol> locals = lvtRanges.getVars(meth, tree);
- for (LocalVar localVar: lvar) {
- for (VarSymbol aliveLocal : locals) {
- if (localVar != null) {
- if (localVar.sym == aliveLocal && localVar.lastRange() != null) {
- char length = (char)(closingCP - localVar.lastRange().start_pc);
- if (length < Character.MAX_VALUE) {
- localVar.closeRange(length);
- }
- }
- }
- }
- }
- }
-
void adjustAliveRanges(int oldCP, int delta) {
for (LocalVar localVar: lvar) {
if (localVar != null) {
@@ -2193,7 +2172,11 @@ public class Code {
boolean keepLocalVariables = varDebugInfo ||
(var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations());
if (!keepLocalVariables) return;
- if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return;
+ //don't keep synthetic vars, unless they are lambda method parameters
+ boolean ignoredSyntheticVar = (var.sym.flags() & Flags.SYNTHETIC) != 0 &&
+ ((var.sym.owner.flags() & Flags.LAMBDA_METHOD) == 0 ||
+ (var.sym.flags() & Flags.PARAMETER) == 0);
+ if (ignoredSyntheticVar) return;
if (varBuffer == null)
varBuffer = new LocalVar[20];
else
diff --git a/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/src/share/classes/com/sun/tools/javac/jvm/Gen.java
index 74a9fa82..f4e4aabe 100644
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -101,10 +101,6 @@ public class Gen extends JCTree.Visitor {
*/
private Pool pool;
- /** LVTRanges info.
- */
- private LVTRanges lvtRanges;
-
private final boolean typeAnnoAsserts;
protected Gen(Context context) {
@@ -137,9 +133,6 @@ public class Gen extends JCTree.Visitor {
options.isUnset(G_CUSTOM)
? options.isSet(G)
: options.isSet(G_CUSTOM, "vars");
- if (varDebugInfo) {
- lvtRanges = LVTRanges.instance(context);
- }
genCrt = options.isSet(XJCOV);
debugCode = options.isSet("debugcode");
allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic");
@@ -493,7 +486,7 @@ public class Gen extends JCTree.Visitor {
JCBlock block = (JCBlock)def;
if ((block.flags & STATIC) != 0)
clinitCode.append(block);
- else
+ else if ((block.flags & SYNTHETIC) == 0)
initCode.append(block);
break;
case METHODDEF:
@@ -521,6 +514,10 @@ public class Gen extends JCTree.Visitor {
clinitTAs.addAll(getAndRemoveNonFieldTAs(sym));
} else {
checkStringConstant(vdef.init.pos(), sym.getConstValue());
+ /* if the init contains a reference to an external class, add it to the
+ * constant's pool
+ */
+ vdef.init.accept(classReferenceVisitor);
}
}
break;
@@ -1103,8 +1100,7 @@ public class Gen extends JCTree.Visitor {
: null,
syms,
types,
- pool,
- varDebugInfo ? lvtRanges : null);
+ pool);
items = new Items(pool, code, syms, types);
if (code.debugCode) {
System.err.println(meth + " for body " + tree);
@@ -1207,30 +1203,14 @@ public class Gen extends JCTree.Visitor {
Chain loopDone = c.jumpFalse();
code.resolve(c.trueJumps);
genStat(body, loopEnv, CRT_STATEMENT | CRT_FLOW_TARGET);
- if (varDebugInfo) {
- checkLoopLocalVarRangeEnding(loop, body,
- LoopLocalVarRangeEndingPoint.BEFORE_STEPS);
- }
code.resolve(loopEnv.info.cont);
genStats(step, loopEnv);
- if (varDebugInfo) {
- checkLoopLocalVarRangeEnding(loop, body,
- LoopLocalVarRangeEndingPoint.AFTER_STEPS);
- }
code.resolve(code.branch(goto_), startpc);
code.resolve(loopDone);
} else {
genStat(body, loopEnv, CRT_STATEMENT | CRT_FLOW_TARGET);
- if (varDebugInfo) {
- checkLoopLocalVarRangeEnding(loop, body,
- LoopLocalVarRangeEndingPoint.BEFORE_STEPS);
- }
code.resolve(loopEnv.info.cont);
genStats(step, loopEnv);
- if (varDebugInfo) {
- checkLoopLocalVarRangeEnding(loop, body,
- LoopLocalVarRangeEndingPoint.AFTER_STEPS);
- }
CondItem c;
if (cond != null) {
code.statBegin(cond.pos);
@@ -1247,44 +1227,6 @@ public class Gen extends JCTree.Visitor {
}
}
- private enum LoopLocalVarRangeEndingPoint {
- BEFORE_STEPS,
- AFTER_STEPS,
- }
-
- /**
- * Checks whether we have reached an alive range ending point for local
- * variables after a loop.
- *
- * Local variables alive range ending point for loops varies depending
- * on the loop type. The range can be closed before or after the code
- * for the steps sentences has been generated.
- *
- * - While loops has no steps so in that case the range is closed just
- * after the body of the loop.
- *
- * - For-like loops may have steps so as long as the steps sentences
- * can possibly contain non-synthetic local variables, the alive range
- * for local variables must be closed after the steps in this case.
- */
- private void checkLoopLocalVarRangeEnding(JCTree loop, JCTree body,
- LoopLocalVarRangeEndingPoint endingPoint) {
- if (varDebugInfo && lvtRanges.containsKey(code.meth, body)) {
- switch (endingPoint) {
- case BEFORE_STEPS:
- if (!loop.hasTag(FORLOOP)) {
- code.closeAliveRanges(body);
- }
- break;
- case AFTER_STEPS:
- if (loop.hasTag(FORLOOP)) {
- code.closeAliveRanges(body);
- }
- break;
- }
- }
- }
-
public void visitForeachLoop(JCEnhancedForLoop tree) {
throw new AssertionError(); // should have been removed by Lower.
}
@@ -1398,9 +1340,6 @@ public class Gen extends JCTree.Visitor {
// Generate code for the statements in this case.
genStats(c.stats, switchEnv, CRT_FLOW_TARGET);
- if (varDebugInfo && lvtRanges.containsKey(code.meth, c.stats.last())) {
- code.closeAliveRanges(c.stats.last());
- }
}
// Resolve all breaks.
@@ -1557,9 +1496,6 @@ public class Gen extends JCTree.Visitor {
genFinalizer(env);
code.statBegin(TreeInfo.endPos(env.tree));
Chain exitChain = code.branch(goto_);
- if (varDebugInfo && lvtRanges.containsKey(code.meth, body)) {
- code.closeAliveRanges(body);
- }
endFinalizerGap(env);
if (startpc != endpc) for (List<JCCatch> l = catchers; l.nonEmpty(); l = l.tail) {
// start off with exception on stack
@@ -1815,17 +1751,11 @@ public class Gen extends JCTree.Visitor {
code.resolve(c.trueJumps);
genStat(tree.thenpart, env, CRT_STATEMENT | CRT_FLOW_TARGET);
thenExit = code.branch(goto_);
- if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.thenpart)) {
- code.closeAliveRanges(tree.thenpart, code.cp);
- }
}
if (elseChain != null) {
code.resolve(elseChain);
if (tree.elsepart != null) {
genStat(tree.elsepart, env,CRT_STATEMENT | CRT_FLOW_TARGET);
- if (varDebugInfo && lvtRanges.containsKey(code.meth, tree.elsepart)) {
- code.closeAliveRanges(tree.elsepart);
- }
}
}
code.resolve(thenExit);
@@ -1863,6 +1793,11 @@ public class Gen extends JCTree.Visitor {
public void visitReturn(JCReturn tree) {
int limit = code.nextreg;
final Env<GenContext> targetEnv;
+
+ /* Save and then restore the location of the return in case a finally
+ * is expanded (with unwind()) in the middle of our bytecodes.
+ */
+ int tmpPos = code.pendingStatPos;
if (tree.expr != null) {
Item r = genExpr(tree.expr, pt).load();
if (hasFinally(env.enclMethod, env)) {
@@ -1870,17 +1805,10 @@ public class Gen extends JCTree.Visitor {
r.store();
}
targetEnv = unwind(env.enclMethod, env);
+ code.pendingStatPos = tmpPos;
r.load();
code.emitop0(ireturn + Code.truncate(Code.typecode(pt)));
} else {
- /* If we have a statement like:
- *
- * return;
- *
- * we need to store the code.pendingStatPos value before generating
- * the finalizer.
- */
- int tmpPos = code.pendingStatPos;
targetEnv = unwind(env.enclMethod, env);
code.pendingStatPos = tmpPos;
code.emitop0(return_);
@@ -2505,25 +2433,18 @@ public class Gen extends JCTree.Visitor {
&& !allowGenerics // no Miranda methods available with generics
)
implementInterfaceMethods(c);
- cdef.defs = normalizeDefs(cdef.defs, c);
c.pool = pool;
pool.reset();
+ /* method normalizeDefs() can add references to external classes into the constant pool
+ * so it should be called after pool.reset()
+ */
+ cdef.defs = normalizeDefs(cdef.defs, c);
generateReferencesToPrunedTree(c, pool);
Env<GenContext> localEnv =
new Env<GenContext>(cdef, new GenContext());
localEnv.toplevel = env.toplevel;
localEnv.enclClass = cdef;
- /* We must not analyze synthetic methods
- */
- if (varDebugInfo && (cdef.sym.flags() & SYNTHETIC) == 0) {
- try {
- new LVTAssignAnalyzer().analyzeTree(localEnv);
- } catch (Throwable e) {
- throw e;
- }
- }
-
for (List<JCTree> l = cdef.defs; l.nonEmpty(); l = l.tail) {
genDef(l.head, localEnv);
}
@@ -2609,282 +2530,4 @@ public class Gen extends JCTree.Visitor {
}
}
- class LVTAssignAnalyzer
- extends Flow.AbstractAssignAnalyzer<LVTAssignAnalyzer.LVTAssignPendingExit> {
-
- final LVTBits lvtInits;
-
- /* This class is anchored to a context dependent tree. The tree can
- * vary inside the same instruction for example in the switch instruction
- * the same FlowBits instance can be anchored to the whole tree, or
- * to a given case. The aim is to always anchor the bits to the tree
- * capable of closing a DA range.
- */
- class LVTBits extends Bits {
-
- JCTree currentTree;
- private int[] oldBits = null;
- BitsState stateBeforeOp;
-
- @Override
- public void clear() {
- generalOp(null, -1, BitsOpKind.CLEAR);
- }
-
- @Override
- protected void internalReset() {
- super.internalReset();
- oldBits = null;
- }
-
- @Override
- public Bits assign(Bits someBits) {
- // bits can be null
- oldBits = bits;
- stateBeforeOp = currentState;
- super.assign(someBits);
- changed();
- return this;
- }
-
- @Override
- public void excludeFrom(int start) {
- generalOp(null, start, BitsOpKind.EXCL_RANGE);
- }
-
- @Override
- public void excl(int x) {
- Assert.check(x >= 0);
- generalOp(null, x, BitsOpKind.EXCL_BIT);
- }
-
- @Override
- public Bits andSet(Bits xs) {
- return generalOp(xs, -1, BitsOpKind.AND_SET);
- }
-
- @Override
- public Bits orSet(Bits xs) {
- return generalOp(xs, -1, BitsOpKind.OR_SET);
- }
-
- @Override
- public Bits diffSet(Bits xs) {
- return generalOp(xs, -1, BitsOpKind.DIFF_SET);
- }
-
- @Override
- public Bits xorSet(Bits xs) {
- return generalOp(xs, -1, BitsOpKind.XOR_SET);
- }
-
- private Bits generalOp(Bits xs, int i, BitsOpKind opKind) {
- Assert.check(currentState != BitsState.UNKNOWN);
- oldBits = dupBits();
- stateBeforeOp = currentState;
- switch (opKind) {
- case AND_SET:
- super.andSet(xs);
- break;
- case OR_SET:
- super.orSet(xs);
- break;
- case XOR_SET:
- super.xorSet(xs);
- break;
- case DIFF_SET:
- super.diffSet(xs);
- break;
- case CLEAR:
- super.clear();
- break;
- case EXCL_BIT:
- super.excl(i);
- break;
- case EXCL_RANGE:
- super.excludeFrom(i);
- break;
- }
- changed();
- return this;
- }
-
- /* The tree we need to anchor the bits instance to.
- */
- LVTBits at(JCTree tree) {
- this.currentTree = tree;
- return this;
- }
-
- /* If the instance should be changed but the tree is not a closing
- * tree then a reset is needed or the former tree can mistakingly be
- * used.
- */
- LVTBits resetTree() {
- this.currentTree = null;
- return this;
- }
-
- /** This method will be called after any operation that causes a change to
- * the bits. Subclasses can thus override it in order to extract information
- * from the changes produced to the bits by the given operation.
- */
- public void changed() {
- if (currentTree != null &&
- stateBeforeOp != BitsState.UNKNOWN &&
- trackTree(currentTree)) {
- List<VarSymbol> locals = lvtRanges
- .getVars(currentMethod, currentTree);
- locals = locals != null ?
- locals : List.<VarSymbol>nil();
- for (JCVariableDecl vardecl : vardecls) {
- //once the first is null, the rest will be so.
- if (vardecl == null) {
- break;
- }
- if (trackVar(vardecl.sym) && bitChanged(vardecl.sym.adr)) {
- locals = locals.prepend(vardecl.sym);
- }
- }
- if (!locals.isEmpty()) {
- lvtRanges.setEntry(currentMethod,
- currentTree, locals);
- }
- }
- }
-
- boolean bitChanged(int x) {
- boolean isMemberOfBits = isMember(x);
- int[] tmp = bits;
- bits = oldBits;
- boolean isMemberOfOldBits = isMember(x);
- bits = tmp;
- return (!isMemberOfBits && isMemberOfOldBits);
- }
-
- boolean trackVar(VarSymbol var) {
- return (var.owner.kind == MTH &&
- (var.flags() & PARAMETER) == 0 &&
- trackable(var));
- }
-
- boolean trackTree(JCTree tree) {
- switch (tree.getTag()) {
- // of course a method closes the alive range of a local variable.
- case METHODDEF:
- // for while loops we want only the body
- case WHILELOOP:
- return false;
- }
- return true;
- }
-
- }
-
- public class LVTAssignPendingExit extends
- Flow.AbstractAssignAnalyzer<LVTAssignPendingExit>.AbstractAssignPendingExit {
-
- LVTAssignPendingExit(JCTree tree, final Bits inits, final Bits uninits) {
- super(tree, inits, uninits);
- }
-
- @Override
- public void resolveJump(JCTree tree) {
- lvtInits.at(tree);
- super.resolveJump(tree);
- }
- }
-
- private LVTAssignAnalyzer() {
- flow.super();
- lvtInits = new LVTBits();
- inits = lvtInits;
- }
-
- @Override
- protected void markDead(JCTree tree) {
- lvtInits.at(tree).inclRange(returnadr, nextadr);
- super.markDead(tree);
- }
-
- @Override
- protected void merge(JCTree tree) {
- lvtInits.at(tree);
- super.merge(tree);
- }
-
- boolean isSyntheticOrMandated(Symbol sym) {
- return (sym.flags() & (SYNTHETIC | MANDATED)) != 0;
- }
-
- @Override
- protected boolean trackable(VarSymbol sym) {
- if (isSyntheticOrMandated(sym)) {
- //fast check to avoid tracking synthetic or mandated variables
- return false;
- }
- return super.trackable(sym);
- }
-
- @Override
- protected void initParam(JCVariableDecl def) {
- if (!isSyntheticOrMandated(def.sym)) {
- super.initParam(def);
- }
- }
-
- @Override
- protected void assignToInits(JCTree tree, Bits bits) {
- lvtInits.at(tree);
- lvtInits.assign(bits);
- }
-
- @Override
- protected void andSetInits(JCTree tree, Bits bits) {
- lvtInits.at(tree);
- lvtInits.andSet(bits);
- }
-
- @Override
- protected void orSetInits(JCTree tree, Bits bits) {
- lvtInits.at(tree);
- lvtInits.orSet(bits);
- }
-
- @Override
- protected void exclVarFromInits(JCTree tree, int adr) {
- lvtInits.at(tree);
- lvtInits.excl(adr);
- }
-
- @Override
- protected LVTAssignPendingExit createNewPendingExit(JCTree tree, Bits inits, Bits uninits) {
- return new LVTAssignPendingExit(tree, inits, uninits);
- }
-
- MethodSymbol currentMethod;
-
- @Override
- public void visitMethodDef(JCMethodDecl tree) {
- if ((tree.sym.flags() & (SYNTHETIC | GENERATEDCONSTR)) != 0
- && (tree.sym.flags() & LAMBDA_METHOD) == 0) {
- return;
- }
- if (tree.name.equals(names.clinit)) {
- return;
- }
- boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0;
- if (enumClass &&
- (tree.name.equals(names.valueOf) ||
- tree.name.equals(names.values) ||
- tree.name.equals(names.init))) {
- return;
- }
- currentMethod = tree.sym;
-
- super.visitMethodDef(tree);
- }
-
- }
-
}
diff --git a/src/share/classes/com/sun/tools/javac/jvm/LVTRanges.java b/src/share/classes/com/sun/tools/javac/jvm/LVTRanges.java
deleted file mode 100644
index 71139ee7..00000000
--- a/src/share/classes/com/sun/tools/javac/jvm/LVTRanges.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-package com.sun.tools.javac.jvm;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.WeakHashMap;
-
-import com.sun.tools.javac.code.Symbol.MethodSymbol;
-import com.sun.tools.javac.code.Symbol.VarSymbol;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.List;
-
-/** This class contains a one to many relation between a tree and a set of variables.
- * The relation implies that the given tree closes the DA (definite assignment)
- * range for the set of variables.
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.</b>
- */
-public class LVTRanges {
- /** The context key for the LVT ranges. */
- protected static final Context.Key<LVTRanges> lvtRangesKey = new Context.Key<>();
-
- /** Get the LVTRanges instance for this context. */
- public static LVTRanges instance(Context context) {
- LVTRanges instance = context.get(lvtRangesKey);
- if (instance == null) {
- instance = new LVTRanges(context);
- }
- return instance;
- }
-
- private static final long serialVersionUID = 1812267524140424433L;
-
- protected Context context;
-
- protected Map<MethodSymbol, Map<JCTree, List<VarSymbol>>>
- aliveRangeClosingTrees = new WeakHashMap<>();
-
- public LVTRanges(Context context) {
- this.context = context;
- context.put(lvtRangesKey, this);
- }
-
- public List<VarSymbol> getVars(MethodSymbol method, JCTree tree) {
- Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method);
- return (varMap != null) ? varMap.get(tree) : null;
- }
-
- public boolean containsKey(MethodSymbol method, JCTree tree) {
- Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method);
- if (varMap == null) {
- return false;
- }
- return varMap.containsKey(tree);
- }
-
- public void setEntry(MethodSymbol method, JCTree tree, List<VarSymbol> vars) {
- Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method);
- if (varMap != null) {
- varMap.put(tree, vars);
- } else {
- varMap = new WeakHashMap<>();
- varMap.put(tree, vars);
- aliveRangeClosingTrees.put(method, varMap);
- }
- }
-
- public List<VarSymbol> removeEntry(MethodSymbol method, JCTree tree) {
- Map<JCTree, List<VarSymbol>> varMap = aliveRangeClosingTrees.get(method);
- if (varMap != null) {
- List<VarSymbol> result = varMap.remove(tree);
- if (varMap.isEmpty()) {
- aliveRangeClosingTrees.remove(method);
- }
- return result;
- }
- return null;
- }
-
- /* This method should be used for debugging LVT related issues.
- */
- @Override
- public String toString() {
- String result = "";
- for (Entry<MethodSymbol, Map<JCTree, List<VarSymbol>>> mainEntry: aliveRangeClosingTrees.entrySet()) {
- result += "Method: \n" + mainEntry.getKey().flatName() + "\n";
- int i = 1;
- for (Entry<JCTree, List<VarSymbol>> treeEntry: mainEntry.getValue().entrySet()) {
- result += " Tree " + i + ": \n" + treeEntry.getKey().toString() + "\n";
- result += " Variables closed:\n";
- for (VarSymbol var: treeEntry.getValue()) {
- result += " " + var.toString();
- }
- result += "\n";
- i++;
- }
- }
- return result;
- }
-
-}
diff --git a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
index 077cc568..c1ae0474 100644
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
@@ -2720,7 +2720,7 @@ public class JavacParser implements Parser {
} else {
JCExpression t = term(EXPR | TYPE);
if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.accepts(token.kind)) {
- return variableDeclarators(modifiersOpt(), t, stats).toList();
+ return variableDeclarators(mods(pos, 0, List.<JCAnnotation>nil()), t, stats).toList();
} else if ((lastmode & TYPE) != 0 && token.kind == COLON) {
error(pos, "bad.initializer", "for-loop");
return List.of((JCStatement)F.at(pos).VarDef(null, null, t, null));
@@ -2829,16 +2829,20 @@ public class JavacParser implements Parser {
default: break;
}
- /* A modifiers tree with no modifier tokens or annotations
- * has no text position. */
- if ((flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0 && annotations.isEmpty())
- pos = Position.NOPOS;
-
- JCModifiers mods = F.at(pos).Modifiers(flags, annotations.toList());
- if (pos != Position.NOPOS)
- storeEnd(mods, S.prevToken().endPos);
- return mods;
+ return mods(pos, flags, annotations.toList());
}
+ //where
+ JCModifiers mods(int pos, long flags, List<JCAnnotation> annotations) {
+ /* A modifiers tree with no modifier tokens or annotations
+ * has no text position. */
+ if ((flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0 && annotations.isEmpty())
+ pos = Position.NOPOS;
+
+ JCModifiers mods = F.at(pos).Modifiers(flags, annotations);
+ if (pos != Position.NOPOS)
+ storeEnd(mods, S.prevToken().endPos);
+ return mods;
+ }
/** Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ]
*
diff --git a/src/share/classes/com/sun/tools/javac/resources/javac.properties b/src/share/classes/com/sun/tools/javac/resources/javac.properties
index 328d9fbf..f4079152 100644
--- a/src/share/classes/com/sun/tools/javac/resources/javac.properties
+++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties
@@ -232,9 +232,9 @@ These options are non-standard and subject to change without notice.
javac.msg.bug=\
An exception has occurred in the compiler ({0}). \
-Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) \
-after checking the Bug Parade for duplicates. \
-Include your program and the following diagnostic in your report. Thank you.
+Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) \
+after checking the Bug Database (http://bugs.java.com) for duplicates. \
+Include your program and the following diagnostic in your report. Thank you.
javac.msg.io=\
\n\nAn input/output error occurred.\n\
diff --git a/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties
index 17d96af7..4d86f6aa 100644
--- a/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties
+++ b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -133,7 +133,7 @@ javac.msg.usage=\u4F7F\u7528\u65B9\u6CD5: {0} <options> <source files>\n\u4F7F\u
javac.msg.usage.nonstandard.footer=\u3053\u308C\u3089\u306F\u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3042\u308A\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002
-javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Parade\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java Developer Connection (http://java.sun.com/webapps/bugreport)\u3067bug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002
+javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Database (http://bugs.java.com)\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java bug\u30EC\u30DD\u30FC\u30C8\u30FB\u30DA\u30FC\u30B8(http://bugreport.java.com)\u3067Java\u30B3\u30F3\u30D1\u30A4\u30E9\u306B\u5BFE\u3059\u308Bbug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002
javac.msg.io=\n\n\u5165\u51FA\u529B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n
diff --git a/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties b/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
index 2ad0c68e..6f9f5f9a 100644
--- a/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
+++ b/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -133,7 +133,7 @@ javac.msg.usage=\u7528\u6CD5: {0} <options> <source files>\n-help \u7528\u4E8E\u
javac.msg.usage.nonstandard.footer=\u8FD9\u4E9B\u9009\u9879\u90FD\u662F\u975E\u6807\u51C6\u9009\u9879, \u5982\u6709\u66F4\u6539, \u6055\u4E0D\u53E6\u884C\u901A\u77E5\u3002
-javac.msg.bug=\u7F16\u8BD1\u5668 ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002 \u5982\u679C\u5728 Bug Parade \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u5728 Java Developer Connection (http://java.sun.com/webapps/bugreport) \u4E2D\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002
+javac.msg.bug=\u7F16\u8BD1\u5668 ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002\u5982\u679C\u5728 Bug Database (http://bugs.java.com) \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u901A\u8FC7 Java Bug \u62A5\u544A\u9875 (http://bugreport.java.com) \u5EFA\u7ACB\u8BE5 Java \u7F16\u8BD1\u5668 Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002
javac.msg.io=\n\n\u53D1\u751F\u8F93\u5165/\u8F93\u51FA\u9519\u8BEF\u3002\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4EE5\u4E0B\u5806\u6808\u8DDF\u8E2A\u3002\n
diff --git a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
index f8d7d583..66a61b1f 100644
--- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
@@ -28,6 +28,7 @@ package com.sun.tools.javac.tree;
import com.sun.source.tree.Tree;
+import com.sun.source.util.TreePath;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Env;
@@ -351,6 +352,18 @@ public class TreeInfo {
return (lit.typetag == BOT);
}
+ /** Return true iff this tree is a child of some annotation. */
+ public static boolean isInAnnotation(Env<?> env, JCTree tree) {
+ TreePath tp = TreePath.getPath(env.toplevel, tree);
+ if (tp != null) {
+ for (Tree t : tp) {
+ if (t.getKind() == Tree.Kind.ANNOTATION)
+ return true;
+ }
+ }
+ return false;
+ }
+
public static String getCommentText(Env<?> env, JCTree tree) {
DocCommentTable docComments = (tree.hasTag(JCTree.Tag.TOPLEVEL))
? ((JCCompilationUnit) tree).docComments
diff --git a/src/share/classes/com/sun/tools/javac/util/Bits.java b/src/share/classes/com/sun/tools/javac/util/Bits.java
index 4319aad3..10efd474 100644
--- a/src/share/classes/com/sun/tools/javac/util/Bits.java
+++ b/src/share/classes/com/sun/tools/javac/util/Bits.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -84,20 +84,6 @@ public class Bits {
}
- public enum BitsOpKind {
- INIT,
- CLEAR,
- INCL_BIT,
- EXCL_BIT,
- ASSIGN,
- AND_SET,
- OR_SET,
- DIFF_SET,
- XOR_SET,
- INCL_RANGE,
- EXCL_RANGE,
- }
-
private final static int wordlen = 32;
private final static int wordshift = 5;
private final static int wordmask = wordlen - 1;
diff --git a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
index ae0cbd2d..11e54b84 100644
--- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java
@@ -124,19 +124,14 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc {
* Returns the flags of a ClassSymbol in terms of javac's flags
*/
static long getFlags(ClassSymbol clazz) {
- while (true) {
- try {
- return clazz.flags();
- } catch (CompletionFailure ex) {
- /* Quietly ignore completion failures.
- * Note that a CompletionFailure can only
- * occur as a result of calling complete(),
- * which will always remove the current
- * completer, leaving it to be null or
- * follow-up completer. Thus the loop
- * is guaranteed to eventually terminate.
- */
- }
+ try {
+ return clazz.flags();
+ } catch (CompletionFailure ex) {
+ /* Quietly ignore completion failures and try again - the type
+ * for which the CompletionFailure was thrown shouldn't be completed
+ * again by the completer that threw the CompletionFailure.
+ */
+ return getFlags(clazz);
}
}
diff --git a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java
index 4d5d191b..7a3449d9 100644
--- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java
+++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java
@@ -128,7 +128,7 @@ public class MethodDocImpl
t.hasTag(CLASS);
t = env.types.supertype(t)) {
ClassSymbol c = (ClassSymbol)t.tsym;
- for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) {
+ for (Scope.Entry e = membersOf(c).lookup(sym.name); e.scope != null; e = e.next()) {
if (sym.overrides(e.sym, origin, env.types, true)) {
return TypeMaker.getType(env, t);
}
@@ -160,7 +160,7 @@ public class MethodDocImpl
t.hasTag(CLASS);
t = env.types.supertype(t)) {
ClassSymbol c = (ClassSymbol)t.tsym;
- for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) {
+ for (Scope.Entry e = membersOf(c).lookup(sym.name); e.scope != null; e = e.next()) {
if (sym.overrides(e.sym, origin, env.types, true)) {
return env.getMethodDoc((MethodSymbol)e.sym);
}
@@ -169,6 +169,19 @@ public class MethodDocImpl
return null;
}
+ /**Retrieve members of c, ignoring any CompletionFailures that occur. */
+ private Scope membersOf(ClassSymbol c) {
+ try {
+ return c.members();
+ } catch (CompletionFailure cf) {
+ /* Quietly ignore completion failures and try again - the type
+ * for which the CompletionFailure was thrown shouldn't be completed
+ * again by the completer that threw the CompletionFailure.
+ */
+ return membersOf(c);
+ }
+ }
+
/**
* Tests whether this method overrides another.
* The overridden method may be one declared in a superclass or
diff --git a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java
index de4d54a6..5fc23819 100644
--- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java
+++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java
@@ -28,6 +28,7 @@ package com.sun.tools.javadoc;
import com.sun.javadoc.*;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.CompletionFailure;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.Type.ArrayType;
import com.sun.tools.javac.code.Type.ClassType;
@@ -56,9 +57,22 @@ public class TypeMaker {
return getType(env, t, errorToClassDoc, true);
}
- @SuppressWarnings("fallthrough")
public static com.sun.javadoc.Type getType(DocEnv env, Type t,
boolean errToClassDoc, boolean considerAnnotations) {
+ try {
+ return getTypeImpl(env, t, errToClassDoc, considerAnnotations);
+ } catch (CompletionFailure cf) {
+ /* Quietly ignore completion failures and try again - the type
+ * for which the CompletionFailure was thrown shouldn't be completed
+ * again by the completer that threw the CompletionFailure.
+ */
+ return getType(env, t, errToClassDoc, considerAnnotations);
+ }
+ }
+
+ @SuppressWarnings("fallthrough")
+ private static com.sun.javadoc.Type getTypeImpl(DocEnv env, Type t,
+ boolean errToClassDoc, boolean considerAnnotations) {
if (env.legacyDoclet) {
t = env.types.erasure(t);
}
diff --git a/src/share/classes/com/sun/tools/jdeps/Analyzer.java b/src/share/classes/com/sun/tools/jdeps/Analyzer.java
index afaa38e8..31d3ea60 100644
--- a/src/share/classes/com/sun/tools/jdeps/Analyzer.java
+++ b/src/share/classes/com/sun/tools/jdeps/Analyzer.java
@@ -223,7 +223,7 @@ public class Analyzer {
Archive targetArchive = findArchive(t);
if (filter.accepts(o, archive, t, targetArchive)) {
addDep(o, t);
- if (!requires.contains(targetArchive)) {
+ if (archive != targetArchive && !requires.contains(targetArchive)) {
requires.add(targetArchive);
}
}
diff --git a/src/share/classes/com/sun/tools/jdeps/JdepsTask.java b/src/share/classes/com/sun/tools/jdeps/JdepsTask.java
index e75e9c76..2c72d57e 100644
--- a/src/share/classes/com/sun/tools/jdeps/JdepsTask.java
+++ b/src/share/classes/com/sun/tools/jdeps/JdepsTask.java
@@ -489,9 +489,11 @@ class JdepsTask {
List<Archive> archives = new ArrayList<>();
Deque<String> roots = new LinkedList<>();
+ List<Path> paths = new ArrayList<>();
for (String s : classes) {
Path p = Paths.get(s);
if (Files.exists(p)) {
+ paths.add(p);
archives.add(Archive.getInstance(p));
} else {
if (isValidClassName(s)) {
@@ -504,7 +506,7 @@ class JdepsTask {
sourceLocations.addAll(archives);
List<Archive> classpaths = new ArrayList<>(); // for class file lookup
- classpaths.addAll(getClassPathArchives(options.classpath));
+ classpaths.addAll(getClassPathArchives(options.classpath, paths));
if (options.includePattern != null) {
archives.addAll(classpaths);
}
@@ -545,6 +547,9 @@ class JdepsTask {
deque.add(cn);
}
a.addClass(d.getOrigin(), d.getTarget());
+ } else {
+ // ensure that the parsed class is added the archive
+ a.addClass(d.getOrigin());
}
}
for (String name : a.reader().skippedEntries()) {
@@ -592,6 +597,9 @@ class JdepsTask {
if (!doneClasses.contains(cn) && !deque.contains(cn)) {
deque.add(cn);
}
+ } else {
+ // ensure that the parsed class is added the archive
+ a.addClass(d.getOrigin());
}
}
}
@@ -743,36 +751,52 @@ class JdepsTask {
}
}
- private List<Archive> getClassPathArchives(String paths) throws IOException {
+ /*
+ * Returns the list of Archive specified in cpaths and not included
+ * initialArchives
+ */
+ private List<Archive> getClassPathArchives(String cpaths, List<Path> initialArchives)
+ throws IOException
+ {
List<Archive> result = new ArrayList<>();
- if (paths.isEmpty()) {
+ if (cpaths.isEmpty()) {
return result;
}
- for (String p : paths.split(File.pathSeparator)) {
+
+ List<Path> paths = new ArrayList<>();
+ for (String p : cpaths.split(File.pathSeparator)) {
if (p.length() > 0) {
- List<Path> files = new ArrayList<>();
// wildcard to parse all JAR files e.g. -classpath dir/*
int i = p.lastIndexOf(".*");
if (i > 0) {
Path dir = Paths.get(p.substring(0, i));
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.jar")) {
for (Path entry : stream) {
- files.add(entry);
+ paths.add(entry);
}
}
} else {
- files.add(Paths.get(p));
- }
- for (Path f : files) {
- if (Files.exists(f)) {
- result.add(Archive.getInstance(f));
- }
+ paths.add(Paths.get(p));
}
}
}
+ for (Path p : paths) {
+ if (Files.exists(p) && !hasSameFile(initialArchives, p)) {
+ result.add(Archive.getInstance(p));
+ }
+ }
return result;
}
+ private boolean hasSameFile(List<Path> paths, Path p2) throws IOException {
+ for (Path p1 : paths) {
+ if (Files.isSameFile(p1, p2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
class RawOutputFormatter implements Analyzer.Visitor {
private final PrintWriter writer;
private String pkg = "";
diff --git a/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java b/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java
index 115f87e3..9fd075c6 100644
--- a/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java
+++ b/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java
@@ -46,7 +46,7 @@ import static com.sun.tools.classfile.Attribute.*;
*/
class PlatformClassPath {
private static final List<String> NON_PLATFORM_JARFILES =
- Arrays.asList("alt-rt.jar", "jfxrt.jar", "ant-javafx.jar", "javafx-mx.jar");
+ Arrays.asList("alt-rt.jar", "ant-javafx.jar", "javafx-mx.jar");
private static final List<Archive> javaHomeArchives = init();
static List<Archive> getArchives() {
@@ -124,6 +124,14 @@ class PlatformClassPath {
*/
static class JDKArchive extends Archive {
private static List<String> PROFILE_JARS = Arrays.asList("rt.jar", "jce.jar");
+ // Workaround: The following packages are not annotated as jdk.Exported
+ private static List<String> EXPORTED_PACKAGES = Arrays.asList(
+ "javax.jnlp",
+ "org.w3c.dom.css",
+ "org.w3c.dom.html",
+ "org.w3c.dom.stylesheets",
+ "org.w3c.dom.xpath"
+ );
public static boolean isProfileArchive(Archive archive) {
if (archive instanceof JDKArchive) {
return PROFILE_JARS.contains(archive.getName());
@@ -155,7 +163,11 @@ class PlatformClassPath {
* Tests if a given package name is exported.
*/
public boolean isExportedPackage(String pn) {
- if (Profile.getProfile(pn) != null || "javax.jnlp".equals(pn)) {
+ if (Profile.getProfile(pn) != null) {
+ return true;
+ }
+ // special case for JavaFX and APIs that are not annotated with @jdk.Exported)
+ if (EXPORTED_PACKAGES.contains(pn) || pn.startsWith("javafx.")) {
return true;
}
return exportedPackages.containsKey(pn) ? exportedPackages.get(pn) : false;