myEnv = enter.getEnv(c);
+ if (myEnv == null || (c.flags_field & TYPE_TRANSLATED) != 0) {
return;
}
+ c.flags_field |= TYPE_TRANSLATED;
/* The two assertions below are set for early detection of any attempt
* to translate a class that:
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/comp/TypeEnvs.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/TypeEnvs.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2014, 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.comp;
+
+import java.util.Collection;
+import java.util.HashMap;
+import com.sun.tools.javac.code.Symbol.TypeSymbol;
+import com.sun.tools.javac.util.Context;
+
+/** This class contains the type environments used by Enter, MemberEnter,
+ * Attr, DeferredAttr, and Lower.
+ *
+ * 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.
+ */
+class TypeEnvs {
+ private static final long serialVersionUID = 571524752489954631L;
+
+ protected static final Context.Key typeEnvsKey = new Context.Key<>();
+ public static TypeEnvs instance(Context context) {
+ TypeEnvs instance = context.get(typeEnvsKey);
+ if (instance == null)
+ instance = new TypeEnvs(context);
+ return instance;
+ }
+
+ private HashMap> map;
+ protected TypeEnvs(Context context) {
+ map = new HashMap<>();
+ context.put(typeEnvsKey, this);
+ }
+
+ Env get(TypeSymbol sym) { return map.get(sym); }
+ Env put(TypeSymbol sym, Env env) { return map.put(sym, env); }
+ Env remove(TypeSymbol sym) { return map.remove(sym); }
+ Collection> values() { return map.values(); }
+ void clear() { map.clear(); }
+}
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/file/Locations.java
--- a/src/share/classes/com/sun/tools/javac/file/Locations.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/file/Locations.java Thu Jun 26 07:56:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -51,6 +51,7 @@
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Options;
+import com.sun.tools.javac.util.StringUtils;
import javax.tools.JavaFileManager;
import javax.tools.StandardJavaFileManager;
@@ -717,7 +718,7 @@
/** Is this the name of an archive file? */
private boolean isArchive(File file) {
- String n = file.getName().toLowerCase();
+ String n = StringUtils.toLowerCase(file.getName());
return fsInfo.isFile(file)
&& (n.endsWith(".jar") || n.endsWith(".zip"));
}
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/jvm/Code.java
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Jun 26 07:56:29 2014 -0700
@@ -1925,6 +1925,13 @@
return aliveRanges.isEmpty() ? null : aliveRanges.get(aliveRanges.size() - 1);
}
+ void removeLastRange() {
+ Range lastRange = lastRange();
+ if (lastRange != null) {
+ aliveRanges.remove(lastRange);
+ }
+ }
+
@Override
public String toString() {
if (aliveRanges == null) {
@@ -1955,9 +1962,7 @@
}
}
} else {
- if (!aliveRanges.isEmpty()) {
- aliveRanges.remove(aliveRanges.size() - 1);
- }
+ removeLastRange();
}
}
@@ -1965,16 +1970,14 @@
if (aliveRanges.isEmpty()) {
return false;
}
- Range range = lastRange();
- return range.length == Character.MAX_VALUE;
+ return lastRange().length == Character.MAX_VALUE;
}
public boolean isLastRangeInitialized() {
if (aliveRanges.isEmpty()) {
return false;
}
- Range range = lastRange();
- return range.start_pc != Character.MAX_VALUE;
+ return lastRange().start_pc != Character.MAX_VALUE;
}
public Range getWidestRange() {
@@ -2095,7 +2098,7 @@
v.closeRange(length);
putVar(v);
} else {
- v.lastRange().start_pc = Character.MAX_VALUE;
+ v.removeLastRange();
}
}
}
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/jvm/Gen.java
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Jun 26 07:56:29 2014 -0700
@@ -1811,8 +1811,7 @@
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,
- thenExit != null && tree.elsepart == null ? thenExit.pc : code.cp);
+ code.closeAliveRanges(tree.thenpart, code.cp);
}
}
if (elseChain != null) {
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/main/Option.java
--- a/src/share/classes/com/sun/tools/javac/main/Option.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/main/Option.java Thu Jun 26 07:56:29 2014 -0700
@@ -47,6 +47,7 @@
import com.sun.tools.javac.util.Log.PrefixKind;
import com.sun.tools.javac.util.Log.WriterKind;
import com.sun.tools.javac.util.Options;
+import com.sun.tools.javac.util.StringUtils;
import static com.sun.tools.javac.main.Option.ChoiceKind.*;
import static com.sun.tools.javac.main.Option.OptionGroup.*;
import static com.sun.tools.javac.main.Option.OptionKind.*;
@@ -713,7 +714,7 @@
String v = options.get(XPKGINFO);
return (v == null
? PkgInfo.LEGACY
- : PkgInfo.valueOf(v.toUpperCase()));
+ : PkgInfo.valueOf(StringUtils.toUpperCase(v)));
}
}
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java
--- a/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Thu Jun 26 07:56:29 2014 -0700
@@ -57,6 +57,7 @@
import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Options;
import com.sun.tools.javac.util.Position;
+import com.sun.tools.javac.util.StringUtils;
import static com.sun.tools.javac.util.LayoutCharacters.*;
/**
@@ -993,7 +994,7 @@
"h1", "h2", "h3", "h4", "h5", "h6", "p", "pre"));
protected boolean isSentenceBreak(Name n) {
- return htmlBlockTags.contains(n.toString().toLowerCase());
+ return htmlBlockTags.contains(StringUtils.toLowerCase(n.toString()));
}
protected boolean isSentenceBreak(DCTree t) {
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/parser/JavacParser.java
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Jun 26 07:56:29 2014 -0700
@@ -4068,15 +4068,16 @@
*/
protected static class SimpleEndPosTable extends AbstractEndPosTable {
- private final Map endPosMap;
+ private final IntHashTable endPosMap;
SimpleEndPosTable(JavacParser parser) {
super(parser);
- endPosMap = new HashMap();
+ endPosMap = new IntHashTable();
}
public void storeEnd(JCTree tree, int endpos) {
- endPosMap.put(tree, errorEndPos > endpos ? errorEndPos : endpos);
+ endPosMap.putAtIndex(tree, errorEndPos > endpos ? errorEndPos : endpos,
+ endPosMap.lookup(tree));
}
protected T to(T t) {
@@ -4090,14 +4091,15 @@
}
public int getEndPos(JCTree tree) {
- Integer value = endPosMap.get(tree);
- return (value == null) ? Position.NOPOS : value;
+ int value = endPosMap.getFromIndex(endPosMap.lookup(tree));
+ // As long as Position.NOPOS==-1, this just returns value.
+ return (value == -1) ? Position.NOPOS : value;
}
public int replaceTree(JCTree oldTree, JCTree newTree) {
- Integer pos = endPosMap.remove(oldTree);
- if (pos != null) {
- endPosMap.put(newTree, pos);
+ int pos = endPosMap.remove(oldTree);
+ if (pos != -1) {
+ storeEnd(newTree, pos);
return pos;
}
return Position.NOPOS;
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
--- a/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java Thu Jun 26 07:56:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -36,6 +36,7 @@
import java.io.PrintWriter;
import java.io.Writer;
import java.util.*;
+import com.sun.tools.javac.util.StringUtils;
/**
* A processor which prints out elements. Used to implement the
@@ -202,7 +203,7 @@
writer.print("@interface");
break;
default:
- writer.print(kind.toString().toLowerCase());
+ writer.print(StringUtils.toLowerCase(kind.toString()));
}
writer.print(" ");
writer.print(e.getSimpleName());
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/resources/compiler.properties
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Jun 26 07:56:29 2014 -0700
@@ -2390,6 +2390,11 @@
static interface methods are not supported in -source {0}\n\
(use -source 8 or higher to enable static interface methods)
+# 0: string
+compiler.err.static.intf.method.invoke.not.supported.in.source=\
+ static interface method invocations are not supported in -source {0}\n\
+ (use -source 8 or higher to enable static interface method invocations)
+
########################################
# Diagnostics for verbose resolution
# used by Resolve (debug only)
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
--- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu Jun 26 07:56:29 2014 -0700
@@ -135,6 +135,14 @@
}
}
+ public static boolean isReceiverParam(JCTree tree) {
+ if (tree.hasTag(VARDEF)) {
+ return ((JCVariableDecl)tree).nameexpr != null;
+ } else {
+ return false;
+ }
+ }
+
/** Is there a constructor declaration in the given list of trees?
*/
public static boolean hasConstructors(List trees) {
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/util/IntHashTable.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/util/IntHashTable.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2014, 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.util;
+
+/**
+ * A hash table that maps Object to int.
+ *
+ * This is a custom hash table optimised for the Object -> int
+ * maps. This is done to avoid unnecessary object allocation in the image set.
+ *
+ * @author Charles Turner
+ * @author Per Bothner
+ */
+public class IntHashTable {
+ private static final int DEFAULT_INITIAL_SIZE = 64;
+ protected Object[] objs; // the domain set
+ protected int[] ints; // the image set
+ protected int mask; // used to clip int's into the domain
+ protected int num_bindings; // the number of mappings (including DELETED)
+ private final static Object DELETED = new Object();
+
+ /**
+ * Construct an Object -> int hash table.
+ *
+ * The default size of the hash table is 64 mappings.
+ */
+ public IntHashTable() {
+ objs = new Object[DEFAULT_INITIAL_SIZE];
+ ints = new int[DEFAULT_INITIAL_SIZE];
+ mask = DEFAULT_INITIAL_SIZE - 1;
+ }
+
+ /**
+ * Construct an Object -> int hash table with a specified amount of mappings.
+ * @param capacity The number of default mappings in this hash table.
+ */
+ public IntHashTable(int capacity) {
+ int log2Size = 4;
+ while (capacity > (1 << log2Size)) {
+ log2Size++;
+ }
+ capacity = 1 << log2Size;
+ objs = new Object[capacity];
+ ints = new int[capacity];
+ mask = capacity - 1;
+ }
+
+ /**
+ * Compute the hash code of a given object.
+ *
+ * @param key The object whose hash code is to be computed.
+ * @return zero if the object is null, otherwise the identityHashCode
+ */
+ public int hash(Object key) {
+ return System.identityHashCode(key);
+ }
+
+ /**
+ * Find either the index of a key's value, or the index of an available space.
+ *
+ * @param key The key to whose value you want to find.
+ * @param hash The hash code of this key.
+ * @return Either the index of the key's value, or an index pointing to
+ * unoccupied space.
+ */
+ public int lookup(Object key, int hash) {
+ Object node;
+ int hash1 = hash ^ (hash >>> 15);
+ int hash2 = (hash ^ (hash << 6)) | 1; //ensure coprimeness
+ int deleted = -1;
+ for (int i = hash1 & mask;; i = (i + hash2) & mask) {
+ node = objs[i];
+ if (node == key)
+ return i;
+ if (node == null)
+ return deleted >= 0 ? deleted : i;
+ if (node == DELETED && deleted < 0)
+ deleted = i;
+ }
+ }
+
+ /**
+ * Lookup a given key's value in the hash table.
+ *
+ * @param key The key whose value you want to find.
+ * @return Either the index of the key's value, or an index pointing to
+ * unoccupied space.
+ */
+ public int lookup(Object key) {
+ return lookup(key, hash(key));
+ }
+
+ /**
+ * Return the value stored at the specified index in the table.
+ *
+ * @param index The index to inspect, as returned from {@link #lookup}
+ * @return A non-negative integer if the index contains a non-null
+ * value, or -1 if it does.
+ */
+ public int getFromIndex(int index) {
+ Object node = objs[index];
+ return node == null || node == DELETED ? -1 : ints[index];
+ }
+
+ /**
+ * Associates the specified key with the specified value in this map.
+ *
+ * @param key key with which the specified value is to be associated.
+ * @param value value to be associated with the specified key.
+ * @param index the index at which to place this binding, as returned
+ * from {@link #lookup}.
+ * @return previous value associated with specified key, or -1 if there was
+ * no mapping for key.
+ */
+ public int putAtIndex(Object key, int value, int index) {
+ Object old = objs[index];
+ if (old == null || old == DELETED) {
+ objs[index] = key;
+ ints[index] = value;
+ if (old != DELETED)
+ num_bindings++;
+ if (3 * num_bindings >= 2 * objs.length)
+ rehash();
+ return -1;
+ } else { // update existing mapping
+ int oldValue = ints[index];
+ ints[index] = value;
+ return oldValue;
+ }
+ }
+
+ public int remove(Object key) {
+ int index = lookup(key);
+ Object old = objs[index];
+ if (old == null || old == DELETED)
+ return -1;
+ objs[index] = DELETED;
+ return ints[index];
+ }
+
+ /**
+ * Expand the hash table when it exceeds the load factor.
+ *
+ * Rehash the existing objects.
+ */
+ protected void rehash() {
+ Object[] oldObjsTable = objs;
+ int[] oldIntsTable = ints;
+ int oldCapacity = oldObjsTable.length;
+ int newCapacity = oldCapacity << 1;
+ Object[] newObjTable = new Object[newCapacity];
+ int[] newIntTable = new int[newCapacity];
+ int newMask = newCapacity - 1;
+ objs = newObjTable;
+ ints = newIntTable;
+ mask = newMask;
+ num_bindings = 0; // this is recomputed below
+ Object key;
+ for (int i = oldIntsTable.length; --i >= 0;) {
+ key = oldObjsTable[i];
+ if (key != null && key != DELETED)
+ putAtIndex(key, oldIntsTable[i], lookup(key, hash(key)));
+ }
+ }
+
+ /**
+ * Removes all mappings from this map.
+ */
+ public void clear() {
+ for (int i = objs.length; --i >= 0;) {
+ objs[i] = null;
+ }
+ num_bindings = 0;
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java
--- a/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Thu Jun 26 07:56:29 2014 -0700
@@ -355,13 +355,41 @@
private final DiagnosticType type;
private final DiagnosticSource source;
private final DiagnosticPosition position;
- private final int line;
- private final int column;
private final String key;
protected final Object[] args;
private final Set flags;
private final LintCategory lintCategory;
+ /** source line position (set lazily) */
+ private SourcePosition sourcePosition;
+
+ /**
+ * This class is used to defer the line/column position fetch logic after diagnostic construction.
+ */
+ class SourcePosition {
+
+ private final int line;
+ private final int column;
+
+ SourcePosition() {
+ int n = (position == null ? Position.NOPOS : position.getPreferredPosition());
+ if (n == Position.NOPOS || source == null)
+ line = column = -1;
+ else {
+ line = source.getLineNumber(n);
+ column = source.getColumnNumber(n, true);
+ }
+ }
+
+ public int getLineNumber() {
+ return line;
+ }
+
+ public int getColumnNumber() {
+ return column;
+ }
+ }
+
/**
* Create a diagnostic object.
* @param formatter the formatter to use for the diagnostic
@@ -391,14 +419,6 @@
this.position = pos;
this.key = key;
this.args = args;
-
- int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition());
- if (n == Position.NOPOS || source == null)
- line = column = -1;
- else {
- line = source.getLineNumber(n);
- column = source.getColumnNumber(n, true);
- }
}
/**
@@ -495,7 +515,10 @@
* @return the line number within the source referred to by this diagnostic
*/
public long getLineNumber() {
- return line;
+ if (sourcePosition == null) {
+ sourcePosition = new SourcePosition();
+ }
+ return sourcePosition.getLineNumber();
}
/**
@@ -503,7 +526,10 @@
* @return the column number within the line of source referred to by this diagnostic
*/
public long getColumnNumber() {
- return column;
+ if (sourcePosition == null) {
+ sourcePosition = new SourcePosition();
+ }
+ return sourcePosition.getColumnNumber();
}
/**
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javac/util/StringUtils.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/util/StringUtils.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013, 2014, 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.util;
+
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** A collection of utilities for String manipulation.
+ *
+ * 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.
+ */
+public class StringUtils {
+
+ /**Converts the given String to lower case using the {@link Locale#US US Locale}. The result
+ * is independent of the default Locale in the current JVM instance.
+ */
+ public static String toLowerCase(String source) {
+ return source.toLowerCase(Locale.US);
+ }
+
+ /**Converts the given String to upper case using the {@link Locale#US US Locale}. The result
+ * is independent of the default Locale in the current JVM instance.
+ */
+ public static String toUpperCase(String source) {
+ return source.toUpperCase(Locale.US);
+ }
+
+ /**Case insensitive version of {@link String#indexOf(java.lang.String)}. Equivalent to
+ * {@code text.indexOf(str)}, except the matching is case insensitive.
+ */
+ public static int indexOfIgnoreCase(String text, String str) {
+ return indexOfIgnoreCase(text, str, 0);
+ }
+
+ /**Case insensitive version of {@link String#indexOf(java.lang.String, int)}. Equivalent to
+ * {@code text.indexOf(str, startIndex)}, except the matching is case insensitive.
+ */
+ public static int indexOfIgnoreCase(String text, String str, int startIndex) {
+ Matcher m = Pattern.compile(Pattern.quote(str), Pattern.CASE_INSENSITIVE).matcher(text);
+ return m.find(startIndex) ? m.start() : -1;
+ }
+
+}
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javap/AttributeWriter.java
--- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java Thu Jun 26 07:56:29 2014 -0700
@@ -62,6 +62,7 @@
import com.sun.tools.classfile.Synthetic_attribute;
import static com.sun.tools.classfile.AccessFlags.*;
+import com.sun.tools.javac.util.StringUtils;
/*
* A writer for writing Attributes as text.
@@ -690,14 +691,14 @@
}
static String toHex(int i) {
- return Integer.toString(i, 16).toUpperCase();
+ return StringUtils.toUpperCase(Integer.toString(i, 16));
}
static String toHex(int i, int w) {
- String s = Integer.toHexString(i).toUpperCase();
+ String s = StringUtils.toUpperCase(Integer.toHexString(i));
while (s.length() < w)
s = "0" + s;
- return s.toUpperCase();
+ return StringUtils.toUpperCase(s);
}
private AnnotationWriter annotationWriter;
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java
--- a/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/javap/TypeAnnotationWriter.java Thu Jun 26 07:56:29 2014 -0700
@@ -37,6 +37,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import com.sun.tools.javac.util.StringUtils;
/**
* Annotate instructions with details about type annotations.
@@ -115,7 +116,7 @@
print("@");
annotationWriter.write(n.anno, false, true);
print(", ");
- println(n.kind.toString().toLowerCase());
+ println(StringUtils.toLowerCase(n.kind.toString()));
}
}
}
diff -r c8b8cabfc922 -r c14269602ffd src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java
--- a/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Wed Jun 18 12:56:12 2014 -0700
+++ b/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java Thu Jun 26 07:56:29 2014 -0700
@@ -49,6 +49,7 @@
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.javac.util.StringUtils;
import com.sun.tools.sjavac.comp.Dependencies;
import com.sun.tools.sjavac.comp.JavaCompilerWithDeps;
import com.sun.tools.sjavac.comp.SmartFileManager;
@@ -256,7 +257,7 @@
// Load visible sources
Set visibleSources = new HashSet();
boolean fix_drive_letter_case =
- System.getProperty("os.name").toLowerCase().startsWith("windows");
+ StringUtils.toLowerCase(System.getProperty("os.name")).startsWith("windows");
for (;;) {
String l = in.readLine();
if (l == null)
diff -r c8b8cabfc922 -r c14269602ffd test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java
--- a/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java Wed Jun 18 12:56:12 2014 -0700
+++ b/test/com/sun/javadoc/testRelativeLinks/TestRelativeLinks.java Thu Jun 26 07:56:29 2014 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4460354 8014636
+ * @bug 4460354 8014636 8043186
* @summary Test to make sure that relative paths are redirected in the
* output so that they are not broken.
* @author jamieh
diff -r c8b8cabfc922 -r c14269602ffd test/com/sun/javadoc/testRelativeLinks/pkg/C.java
--- a/test/com/sun/javadoc/testRelativeLinks/pkg/C.java Wed Jun 18 12:56:12 2014 -0700
+++ b/test/com/sun/javadoc/testRelativeLinks/pkg/C.java Thu Jun 26 07:56:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, 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
@@ -30,7 +30,7 @@
public class C {
/**
- * Here is a relative link in a field:
+ * Here is a relative link in a field:\u0130
* relative field link.
*/
public C field = null;
diff -r c8b8cabfc922 -r c14269602ffd test/com/sun/javadoc/testTopOption/TestTopOption.java
--- a/test/com/sun/javadoc/testTopOption/TestTopOption.java Wed Jun 18 12:56:12 2014 -0700
+++ b/test/com/sun/javadoc/testTopOption/TestTopOption.java Thu Jun 26 07:56:29 2014 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6227616
+ * @bug 6227616 8043186
* @summary Test the new -top option.
* @author jamieh
* @library ../lib/
@@ -39,7 +39,7 @@
//Javadoc arguments.
private static final String[] ARGS = new String[] {
- "-overview", "SRC_DIR + FS + overview.html", "-use", "-top", "TOP TEXT", "-d", BUG_ID, "-sourcepath",
+ "-overview", SRC_DIR + FS + "overview.html", "-use", "-top", "\u0130{@docroot}TOP TEXT", "-d", BUG_ID, "-sourcepath",
SRC_DIR, "pkg"
};
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/NoStringToLower.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/NoStringToLower.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,136 @@
+/*
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8029800
+ * @summary String.toLowerCase()/toUpperCase is generally dangerous, check it is not used in langtools
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.tools.*;
+import com.sun.tools.classfile.*;
+import com.sun.tools.classfile.ConstantPool.CONSTANT_Methodref_info;
+
+public class NoStringToLower {
+ public static void main(String... args) throws Exception {
+ NoStringToLower c = new NoStringToLower();
+ if (c.run(args))
+ return;
+
+ if (is_jtreg())
+ throw new Exception(c.errors + " errors occurred");
+ else
+ System.exit(1);
+ }
+
+ static boolean is_jtreg() {
+ return (System.getProperty("test.src") != null);
+ }
+
+ /**
+ * Main entry point.
+ */
+ boolean run(String... args) throws Exception {
+ JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+ JavaFileManager fm = c.getStandardFileManager(null, null, null);
+ JavaFileManager.Location javacLoc = findJavacLocation(fm);
+ String[] pkgs = {
+ "javax.annotation.processing",
+ "javax.lang.model",
+ "javax.tools",
+ "com.sun.source",
+ "com.sun.tools.classfile",
+ "com.sun.tools.doclet",
+ "com.sun.tools.doclint",
+ "com.sun.tools.javac",
+ "com.sun.tools.javadoc",
+ "com.sun.tools.javah",
+ "com.sun.tools.javap",
+ "com.sun.tools.jdeps",
+ "com.sun.tools.sjavac"
+ };
+ for (String pkg: pkgs) {
+ for (JavaFileObject fo: fm.list(javacLoc,
+ pkg, EnumSet.of(JavaFileObject.Kind.CLASS), true)) {
+ scan(fo);
+ }
+ }
+
+ return (errors == 0);
+ }
+
+ // depending on how the test is run, javac may be on bootclasspath or classpath
+ JavaFileManager.Location findJavacLocation(JavaFileManager fm) {
+ JavaFileManager.Location[] locns =
+ { StandardLocation.PLATFORM_CLASS_PATH, StandardLocation.CLASS_PATH };
+ try {
+ for (JavaFileManager.Location l: locns) {
+ JavaFileObject fo = fm.getJavaFileForInput(l,
+ "com.sun.tools.javac.Main", JavaFileObject.Kind.CLASS);
+ if (fo != null)
+ return l;
+ }
+ } catch (IOException e) {
+ throw new Error(e);
+ }
+ throw new IllegalStateException("Cannot find javac");
+ }
+
+ /**
+ * Verify there are no references to String.toLowerCase() in a class file.
+ */
+ void scan(JavaFileObject fo) throws IOException {
+ InputStream in = fo.openInputStream();
+ try {
+ ClassFile cf = ClassFile.read(in);
+ for (ConstantPool.CPInfo cpinfo: cf.constant_pool.entries()) {
+ if (cpinfo.getTag() == ConstantPool.CONSTANT_Methodref) {
+ CONSTANT_Methodref_info ref = (CONSTANT_Methodref_info) cpinfo;
+ String methodDesc = ref.getClassInfo().getName() + "." + ref.getNameAndTypeInfo().getName() + ":" + ref.getNameAndTypeInfo().getType();
+
+ if ("java/lang/String.toLowerCase:()Ljava/lang/String;".equals(methodDesc)) {
+ error("found reference to String.toLowerCase() in: " + fo.getName());
+ }
+ if ("java/lang/String.toUpperCase:()Ljava/lang/String;".equals(methodDesc)) {
+ error("found reference to String.toLowerCase() in: " + fo.getName());
+ }
+ }
+ }
+ } catch (ConstantPoolException ignore) {
+ } finally {
+ in.close();
+ }
+ }
+
+ /**
+ * Report an error.
+ */
+ void error(String msg) {
+ System.err.println("Error: " + msg);
+ errors++;
+ }
+
+ int errors;
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/T8038975/AccessTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T8038975/AccessTest.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8038975
+ * @summary Access control in enhanced for
+ * @compile AccessTest.java
+ */
+
+import a.*;
+public class AccessTest {
+ private static class Impl extends B {
+ public void method(Inner inner) {
+ for (A a : inner)
+ System.out.println(a);
+ }
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/T8038975/a/A.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T8038975/a/A.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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 a;
+public class A { }
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/T8038975/a/B.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T8038975/a/B.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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 a;
+public class B {
+ protected abstract class Inner implements Iterable { }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/annotations/FinalReceiverTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/FinalReceiverTest.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8027886
+ * @summary Receiver parameters must not be final
+ * @compile/fail/ref=FinalReceiverTest.out -XDrawDiagnostics FinalReceiverTest.java
+ */
+
+class FinalReceiverTest {
+ void m() {
+ class Inner {
+ Inner(final FinalReceiverTest FinalReceiverTest.this) {}
+ }
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/annotations/FinalReceiverTest.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/FinalReceiverTest.out Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,2 @@
+FinalReceiverTest.java:11:43: compiler.err.mod.not.allowed.here: final
+1 error
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/annotations/LocalInnerReceiverTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/LocalInnerReceiverTest.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8029042
+ * @summary Receiver parameter not supported on local class constructor
+ * @compile LocalInnerReceiverTest.java
+ */
+
+class LocalInnerReceiverTest {
+ void m() {
+ class Inner {
+ Inner(LocalInnerReceiverTest LocalInnerReceiverTest.this) {}
+ }
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java
--- a/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java Wed Jun 18 12:56:12 2014 -0700
+++ b/test/tools/javac/annotations/typeAnnotations/newlocations/Receivers.java Thu Jun 26 07:56:29 2014 -0700
@@ -54,14 +54,6 @@
void accept(@B("m") WithValue this, T r) throws Exception { }
}
-class WithFinal {
- void plain(final @B("m") WithFinal this) { }
- void generic(final @B("m") WithFinal this) { }
- void withException(final @B("m") WithFinal this) throws Exception { }
- String nonVoid(final @B("m") WithFinal this) { return null; }
- void accept(final @B("m") WithFinal this, T r) throws Exception { }
-}
-
class WithBody {
Object f;
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/defaultMethods/static/StaticInvoke.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/static/StaticInvoke.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,15 @@
+/* @test /nodynamiccopyright/
+ * @bug 8037385
+ * @summary Must not allow static interface method invocation in legacy code
+ * @compile -source 8 -Xlint:-options StaticInvoke.java
+ * @compile/fail/ref=StaticInvoke7.out -source 7 -Xlint:-options -XDrawDiagnostics StaticInvoke.java
+ * @compile/fail/ref=StaticInvoke6.out -source 6 -Xlint:-options -XDrawDiagnostics StaticInvoke.java
+ */
+import java.util.stream.Stream;
+
+class StaticInvoke {
+ void test() {
+ Stream.empty();
+ java.util.stream.Stream.empty();
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/defaultMethods/static/StaticInvoke6.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/static/StaticInvoke6.out Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,3 @@
+StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6
+StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6
+2 errors
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/defaultMethods/static/StaticInvoke7.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/defaultMethods/static/StaticInvoke7.out Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,3 @@
+StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7
+StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7
+2 errors
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/diags/examples/StaticIntfMethodInvokeNotSupported.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/StaticIntfMethodInvokeNotSupported.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+// key: compiler.err.static.intf.method.invoke.not.supported.in.source
+// options: -source 7 -Xlint:-options
+import java.util.stream.Stream;
+
+class StaticIntfMethodInvokeNotSupported {
+ void test() {
+ Stream.empty();
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/flow/LVTHarness.java
--- a/test/tools/javac/flow/LVTHarness.java Wed Jun 18 12:56:12 2014 -0700
+++ b/test/tools/javac/flow/LVTHarness.java Thu Jun 26 07:56:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -23,8 +23,8 @@
/*
* @test
- * @bug 7047734 8027660
- * @summary The LVT is not generated correctly during some try/catch scenarios;
+ * @bug 7047734 8027660 8037937
+ * @summary The LVT is not generated correctly during some try/catch scenarios
* javac crash while creating LVT entry for a local variable defined in
* an inner block
* @library /tools/javac/lib
@@ -120,7 +120,7 @@
for (Map.Entry entry : aliveRangeMap.entrySet()) {
if (!seenAliveRanges.contains(entry.getKey())) {
error("Redundant @AliveRanges annotation on method " +
- entry.getKey().elem);
+ entry.getKey().elem + " with key " + entry.getKey());
}
}
}
@@ -134,7 +134,7 @@
for (Method method : classFile.methods) {
for (ElementKey elementKey: aliveRangeMap.keySet()) {
String methodDesc = method.getName(constantPool) +
- method.descriptor.getParameterTypes(constantPool);
+ method.descriptor.getParameterTypes(constantPool).replace(" ", "");
if (methodDesc.equals(elementKey.elem.toString())) {
checkMethod(constantPool, method, aliveRangeMap.get(elementKey));
seenAliveRanges.add(elementKey);
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/flow/T8042741/A.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/flow/T8042741/A.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+// str must be at absolute position greater than that of lambda
+// expression in PositionTest.java
+// padding..........................................................padding
+// padding..........................................................padding
+// padding..........................................................padding
+// padding..........................................................padding
+// padding..........................................................padding
+
+public class A {
+ public final String str;
+ {
+ str = "";
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/flow/T8042741/PositionTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/flow/T8042741/PositionTest.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+/* @test
+ * @bug 8042741
+ * @summary Java 8 compiler throws NullPointerException depending location in source file
+ * @compile A.java PositionTest.java
+ */
+
+public class PositionTest extends A {
+ void test(SAM r) throws E {
+ test(() -> { System.err.println(str); });
+ }
+ interface SAM {
+ public void run() throws E;
+ }
+ void f() {
+ try {
+ test(() -> {
+ test(() -> {
+ try {
+ test(() -> { System.err.println(str); });
+ System.err.println(str);
+ } catch (Exception e) {}
+ System.err.println(str);
+ });
+ System.err.println(str);
+ });
+ } catch (Exception e) { }
+ }
+ void g() throws Exception {
+ test(() -> {
+ try {
+ try {
+ test(() -> { System.err.println(str); });
+ } catch (Exception e) {}
+ System.err.println(str);
+ } catch (Exception e) {}
+ System.err.println(str);
+ });
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/flow/tests/TestCaseIfElse.java
--- a/test/tools/javac/flow/tests/TestCaseIfElse.java Wed Jun 18 12:56:12 2014 -0700
+++ b/test/tools/javac/flow/tests/TestCaseIfElse.java Thu Jun 26 07:56:29 2014 -0700
@@ -33,7 +33,7 @@
@AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8)
@AliveRange(varName="o", bytecodeStart=21, bytecodeLength=9)
- void m2(String[] args) {
+ void m2() {
Object o;
int i = 5;
if (i != 5) {
@@ -45,4 +45,19 @@
}
o = "finish";
}
+
+ @AliveRange(varName="o", bytecodeStart=11, bytecodeLength=3)
+ @AliveRange(varName="o", bytecodeStart=17, bytecodeLength=2)
+ Object m3(boolean cond1, boolean cond2) {
+ Object o;
+ if (cond1) {
+ if (cond2) {
+ o = "then";
+ } else {
+ o = "else";
+ return null;
+ }
+ }
+ return null;
+ }
}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,11 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8041713
+ * @summary Type inference of non-existent method references crashes the compiler
+ * @compile/fail/ref=DiamondPlusUnexistingMethodRefCrashTest.out -XDrawDiagnostics DiamondPlusUnexistingMethodRefCrashTest.java
+ */
+
+public class DiamondPlusUnexistingMethodRefCrashTest {
+ DiamondPlusUnexistingMethodRefCrashTest m =
+ new DiamondPlusUnexistingMethodRefCrashTest<>(DiamondPlusUnexistingMethodRefCrashTest::doNotExists);
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/diamond/T8041713/DiamondPlusUnexistingMethodRefCrashTest.out Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,2 @@
+DiamondPlusUnexistingMethodRefCrashTest.java:10:55: compiler.err.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, doNotExists, , , (compiler.misc.location: kindname.class, DiamondPlusUnexistingMethodRefCrashTest, null))
+1 error
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/generics/inference/7086586/T7086586.out
--- a/test/tools/javac/generics/inference/7086586/T7086586.out Wed Jun 18 12:56:12 2014 -0700
+++ b/test/tools/javac/generics/inference/7086586/T7086586.out Thu Jun 26 07:56:29 2014 -0700
@@ -1,5 +1,5 @@
-T7086586.java:14:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.String)
-T7086586.java:15:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Number)
-T7086586.java:16:31: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.captureof: 1, ?, java.lang.Exception)
-T7086586.java:17:13: compiler.err.cant.resolve.location.args: kindname.method, nonExistentMethod, , , (compiler.misc.location: kindname.interface, java.util.List, null)
+T7086586.java:14:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List super T>, java.util.List, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List, java.util.List super T>))
+T7086586.java:15:20: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List super T>, java.util.List, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List, java.util.List super T>))
+T7086586.java:16:23: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List super T>, java.util.List, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List, java.util.List super T>))
+T7086586.java:17:9: compiler.err.cant.apply.symbol: kindname.method, m, java.util.List super T>, java.util.List, kindname.class, T7086586, (compiler.misc.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: java.util.List, java.util.List super T>))
4 errors
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/generics/inference/7086586/T7086586b.java
--- a/test/tools/javac/generics/inference/7086586/T7086586b.java Wed Jun 18 12:56:12 2014 -0700
+++ b/test/tools/javac/generics/inference/7086586/T7086586b.java Thu Jun 26 07:56:29 2014 -0700
@@ -23,10 +23,9 @@
/*
* @test
- * @bug 7086586 8033718
+ * @bug 7086586
*
- * @summary Inference producing null type argument; inference ignores capture
- * variable as upper bound
+ * @summary Inference producing null type argument
*/
import java.util.List;
@@ -41,8 +40,8 @@
assertionCount++;
}
- void m(List super T> dummy) { assertTrue(true); }
- void m(Object dummy) { assertTrue(false); }
+ void m(List super T> dummy) { assertTrue(false); }
+ void m(Object dummy) { assertTrue(true); }
void test(List> l) {
m(l);
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/generics/inference/8043725/T8043725.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/8043725/T8043725.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8043725
+ * @summary javac fails with StackOverflowException
+ * @compile T8043725.java
+ */
+class T8043725 {
+ > T m(T v) {
+ //this will generate two upper bounds, T and Comparable respectively
+ //causing infinite recursion in lub (because of JLS 18.3.1).
+ return m(v);
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/generics/inference/NestedWildcards.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/NestedWildcards.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8039214
+ * @summary Nested generic methods that work on wildcard-parameterized types
+ * @compile NestedWildcards.java
+ */
+
+public class NestedWildcards {
+
+ public static void test(Box b) {
+ foo(bar(b));
+ }
+ private static Box extends X> foo(Box extends X> ts) {
+ return null;
+ }
+ public static Box extends Y> bar(Box extends Y> language) {
+ return null;
+ }
+
+ interface Box {}
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/generics/wildcards/7034495/T7034495.out
--- a/test/tools/javac/generics/wildcards/7034495/T7034495.out Wed Jun 18 12:56:12 2014 -0700
+++ b/test/tools/javac/generics/wildcards/7034495/T7034495.out Thu Jun 26 07:56:29 2014 -0700
@@ -1,2 +1,2 @@
-T7034495.java:40:17: compiler.err.types.incompatible.diff.ret: T7034495.B>, T7034495.A>, foo()
+T7034495.java:40:17: compiler.err.types.incompatible.diff.ret: T7034495.B, T7034495.A, foo()
1 error
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/generics/wildcards/T8015101.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/wildcards/T8015101.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8015101
+ * @summary Mishandling of wildcards in intersection member method check
+ * @compile T8015101.java
+ */
+class T8015101 {
+
+ public static class Bug & Runnable> {
+ }
+
+ interface Parent {
+ public C get();
+ }
+
+ interface Child extends Parent {
+ @Override
+ public S get();
+ }
+
+ }
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/generics/wildcards/T8034147.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/wildcards/T8034147.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8034147
+ * @summary javac crashes with a NullPointerException during bounds checking
+ * @compile T8034147.java
+ */
+
+class T8034147 {
+ static class One> {}
+ static class Two> implements Three {}
+ interface Three {}
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/lambda/T8031967.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/T8031967.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8031967
+ * @summary Ensure javac can handle very deeply nested chain of method invocations occurring as
+ * a parameter to other method invocations.
+ * @run main T8031967
+ */
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+
+public class T8031967 {
+
+ public static void main(String... args) throws IOException {
+ new T8031967().run();
+ }
+
+ final int depth = 50;
+
+ private void run() throws IOException {
+ runTestCase(true);
+ runTestCase(false);
+ }
+
+ private void runTestCase(boolean withErrors) throws IOException {
+ StringBuilder code = new StringBuilder();
+
+ code.append("public class Test {\n" +
+ " private void test() {\n" +
+ " GroupLayout l = new GroupLayout();\n" +
+ " l.setHorizontalGroup(\n");
+
+ gen(code, depth);
+ code.append(" );\n" +
+ " }\n");
+ if (!withErrors) {
+ code.append(" class GroupLayout {\n" +
+ " ParallelGroup createParallelGroup() {return null;}\n" +
+ " ParallelGroup createParallelGroup(int i) {return null;}\n" +
+ " ParallelGroup createParallelGroup(int i, int j) {return null;}\n" +
+ " void setHorizontalGroup(Group g) { }\n" +
+ " }\n" +
+ " \n" +
+ " class Group {\n" +
+ " Group addGroup(Group g) { return this; }\n" +
+ " Group addGroup(int i, Group g) { return this; }\n" +
+ " Group addGap(int i) { return this; }\n" +
+ " Group addGap(long l) { return this; }\n" +
+ " Group addGap(int i, int j) { return this; }\n" +
+ " Group addComponent(Object c) { return this; }\n" +
+ " Group addComponent(int i, Object c) { return this; }\n" +
+ " }\n" +
+ " class ParallelGroup extends Group {\n" +
+ " Group addGroup(Group g) { return this; }\n" +
+ " Group addGroup(int i, Group g) { return this; }\n" +
+ " Group addGap(int i) { return this; }\n" +
+ " Group addGap(int i, int j) { return this; }\n" +
+ " Group addComponent(Object c) { return this; }\n" +
+ " Group addComponent(int i, Object c) { return this; }\n" +
+ " }\n");
+ }
+
+ code.append("}\n");
+
+ JavaSource source = new JavaSource(code.toString());
+ List sourceList = Arrays.asList(source);
+ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ DiagnosticListener noErrors = (diagnostic) -> {
+ throw new IllegalStateException("Should not produce errors: " + diagnostic);
+ };
+ JavacTask task = (JavacTask) compiler.getTask(null, null, withErrors ? null : noErrors,
+ null, null, sourceList);
+
+ task.analyze();
+ }
+
+ private void gen(StringBuilder code, int depth) {
+ code.append("l.createParallelGroup()\n");
+ if (depth > 0) {
+ code.append(".addGroup(\n");
+ gen(code, depth - 1);
+ code.append(")");
+ }
+
+ code.append(".addGap(1)\n" +
+ ".addComponent(new Object())\n" +
+ ".addGap(1)\n" +
+ ".addComponent(new Object())");
+ }
+
+ class JavaSource extends SimpleJavaFileObject {
+
+ final String code;
+ public JavaSource(String code) {
+ super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+ this.code = code;
+ }
+
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return code;
+ }
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8038182
+ * @summary javac crash with FunctionDescriptorLookupError for invalid functional interface
+ * @compile/fail/ref=CrashFunctionDescriptorExceptionTest.out -XDrawDiagnostics CrashFunctionDescriptorExceptionTest.java
+ */
+
+class CrashFunctionDescriptorExceptionTest {
+
+ @SuppressWarnings("unchecked")
+ void m () {
+ bar((B b) -> {});
+ }
+
+ > void bar(I i) {}
+
+ class A {}
+
+ class B extends A {}
+
+ interface I> {
+ void foo(E e);
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,2 @@
+CrashFunctionDescriptorExceptionTest.java:12:13: compiler.err.prob.found.req: (compiler.misc.no.suitable.functional.intf.inst: CrashFunctionDescriptorExceptionTest.I)
+1 error
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8042759
+ * @summary Lambda returning implicitly-typed lambdas considered pertinent to applicability
+ * @compile/fail/ref=ImplicitLambdaConsideredForApplicabilityTest.out -XDrawDiagnostics ImplicitLambdaConsideredForApplicabilityTest.java
+ */
+
+abstract class ImplicitLambdaConsideredForApplicabilityTest {
+ interface A {
+ B m(int a, int b);
+ }
+
+ interface C {
+ String m(int a, int b);
+ }
+
+ interface B {
+ int m(int c);
+ }
+
+ abstract void foo(A a);
+
+ abstract void foo(C c);
+
+ void bar() {
+ foo((int a, int b) -> {
+ if(a < b)
+ return c -> 0;
+ else
+ return c -> 0;
+ });
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,2 @@
+ImplicitLambdaConsideredForApplicabilityTest.java:26:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.A), ImplicitLambdaConsideredForApplicabilityTest, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.C), ImplicitLambdaConsideredForApplicabilityTest
+1 error
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java
--- a/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java Wed Jun 18 12:56:12 2014 -0700
+++ b/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java Thu Jun 26 07:56:29 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, 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
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8011027
+ * @bug 8011027 8046916
* @library /tools/javac/lib
* @build JavacTestingAbstractProcessor TestTypeParameterAnnotations
* @compile -processor TestTypeParameterAnnotations -proc:only TestTypeParameterAnnotations.java
@@ -33,10 +33,16 @@
import java.lang.annotation.*;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
-import javax.lang.model.util.*;
import javax.tools.*;
-public class TestTypeParameterAnnotations<@Foo @Bar @Baz T> extends JavacTestingAbstractProcessor {
+@ExpectedTypeParameterAnnotations(typeParameterName="T1",
+ annotations={"Foo1", "Bar1", "Baz1"})
+@ExpectedTypeParameterAnnotations(typeParameterName="T2", annotations={})
+@ExpectedTypeParameterAnnotations(typeParameterName="T3",
+ annotations={"Foo2", "Bar2", "Baz2"})
+@ExpectedTypeParameterAnnotations(typeParameterName="T4", annotations={})
+public class TestTypeParameterAnnotations<@Foo1 @Bar1 @Baz1 T1, T2, @Foo2 @Bar2 @Baz2 T3, T4> extends
+ JavacTestingAbstractProcessor {
int round = 0;
public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {
@@ -74,82 +80,69 @@
int check(Element e, List extends TypeParameterElement> typarams) {
if (typarams.isEmpty())
return 0;
- if (typarams.size() != 1)
- return 0;
- for (TypeParameterElement tpe: typarams) {
- boolean b1 = checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors());
- boolean b2 = checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe));
- boolean b3 = checkGetAnnotation(tpe);
- boolean b4 = checkGetAnnotations(tpe);
- return b1 && b2 && b3 && b4 ? 1 : 0;
+ for (TypeParameterElement tpe : typarams) {
+ ExpectedTypeParameterAnnotations expected = null;
+ for (ExpectedTypeParameterAnnotations a : e.getAnnotationsByType(ExpectedTypeParameterAnnotations.class)) {
+ if (tpe.getSimpleName().contentEquals(a.typeParameterName())) {
+ expected = a;
+ break;
+ }
+ }
+ if (expected == null) {
+ throw new IllegalStateException("Does not have expected values annotation.");
+ }
+ checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors(), expected);
+ checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe), expected);
+ checkGetAnnotation(tpe, expected);
+ checkGetAnnotations(tpe, expected);
}
- return 0;
+
+ return typarams.size();
}
- boolean checkAnnotationMirrors(TypeParameterElement tpe, List extends AnnotationMirror> l) {
- if (l.size() != 3) {
- error("To few annotations, got " + l.size() +
- ", should be 3", tpe);
- return false;
+ void checkAnnotationMirrors(TypeParameterElement tpe, List extends AnnotationMirror> l, ExpectedTypeParameterAnnotations expected) {
+ String[] expectedAnnotations = expected.annotations();
+
+ if (l.size() != expectedAnnotations.length) {
+ error("Incorrect number of annotations, got " + l.size() +
+ ", should be " + expectedAnnotations.length, tpe);
+ return ;
}
- AnnotationMirror m = l.get(0);
- if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Foo"))) {
- error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement());
- return false;
+ for (int i = 0; i < expectedAnnotations.length; i++) {
+ AnnotationMirror m = l.get(i);
+ if (!m.getAnnotationType().asElement().equals(elements.getTypeElement(expectedAnnotations[i]))) {
+ error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement());
+ return ;
+ }
}
- m = l.get(1);
- if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Bar"))) {
- error("Wrong type of annotation, was expecting @Bar", m.getAnnotationType().asElement());
- return false;
- }
- m = l.get(2);
- if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Baz"))) {
- error("Wrong type of annotation, was expecting @Baz", m.getAnnotationType().asElement());
- return false;
- }
- return true;
}
- boolean checkGetAnnotation(TypeParameterElement tpe) {
- Foo f = tpe.getAnnotation(Foo.class);
- if (f == null)
- error("Expecting @Foo to be present in getAnnotation()", tpe);
+ void checkGetAnnotation(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) {
+ List expectedAnnotations = Arrays.asList(expected.annotations());
- Bar b = tpe.getAnnotation(Bar.class);
- if (b == null)
- error("Expecting @Bar to be present in getAnnotation()", tpe);
+ for (Class extends Annotation> c : ALL_ANNOTATIONS) {
+ Object a = tpe.getAnnotation(c);
- Baz z = tpe.getAnnotation(Baz.class);
- if (z == null)
- error("Expecting @Baz to be present in getAnnotation()", tpe);
-
- return f != null &&
- b != null &&
- z != null;
+ if (a != null ^ expectedAnnotations.indexOf(c.getName()) != (-1)) {
+ error("Unexpected behavior for " + c.getName(), tpe);
+ return ;
+ }
+ }
}
- boolean checkGetAnnotations(TypeParameterElement tpe) {
- Foo[] f = tpe.getAnnotationsByType(Foo.class);
- if (f.length != 1) {
- error("Expecting 1 @Foo to be present in getAnnotationsByType()", tpe);
- return false;
+ void checkGetAnnotations(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) {
+ List expectedAnnotations = Arrays.asList(expected.annotations());
+
+ for (Class extends Annotation> c : ALL_ANNOTATIONS) {
+ Object[] a = tpe.getAnnotationsByType(c);
+
+ if (a.length > 0 ^ expectedAnnotations.indexOf(c.getName()) != (-1)) {
+ error("Unexpected behavior for " + c.getName(), tpe);
+ return ;
+ }
}
-
- Bar[] b = tpe.getAnnotationsByType(Bar.class);
- if (b.length != 1) {
- error("Expecting 1 @Bar to be present in getAnnotationsByType()", tpe);
- return false;
- }
-
- Baz[] z = tpe.getAnnotationsByType(Baz.class);
- if (z.length != 1) {
- error("Expecting 1 @Baz to be present in getAnnotationsByType()", tpe);
- return false;
- }
-
- return true;
}
void note(String msg) {
@@ -168,23 +161,71 @@
messager.printMessage(Diagnostic.Kind.ERROR, msg);
}
+ Class extends Annotation>[] ALL_ANNOTATIONS = new Class[] {
+ Foo1.class, Bar1.class, Baz1.class,
+ Foo2.class, Bar2.class, Baz2.class,
+ };
+
// additional generic elements to test
- <@Foo @Bar @Baz X> X m(X x) { return x; }
+ @ExpectedTypeParameterAnnotations(typeParameterName="W",
+ annotations={"Foo1", "Bar1", "Baz1"})
+ @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
+ @ExpectedTypeParameterAnnotations(typeParameterName="Y",
+ annotations={"Foo2", "Bar2", "Baz2"})
+ @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
+ <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> X m(X x) { return x; }
- interface Intf<@Foo @Bar @Baz X> { X m() ; }
+ @ExpectedTypeParameterAnnotations(typeParameterName="W",
+ annotations={"Foo1", "Bar1", "Baz1"})
+ @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
+ @ExpectedTypeParameterAnnotations(typeParameterName="Y",
+ annotations={"Foo2", "Bar2", "Baz2"})
+ @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
+ interface Intf<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> { X m() ; }
- class Class<@Foo @Bar @Baz X> {
- <@Foo @Bar @Baz Y> Class() { }
+ @ExpectedTypeParameterAnnotations(typeParameterName="W",
+ annotations={"Foo1", "Bar1", "Baz1"})
+ @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
+ @ExpectedTypeParameterAnnotations(typeParameterName="Y",
+ annotations={"Foo2", "Bar2", "Baz2"})
+ @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
+ class Clazz<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> {
+ @ExpectedTypeParameterAnnotations(typeParameterName="W",
+ annotations={"Foo1", "Bar1", "Baz1"})
+ @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={})
+ @ExpectedTypeParameterAnnotations(typeParameterName="Y",
+ annotations={"Foo2", "Bar2", "Baz2"})
+ @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={})
+ <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> Clazz() { }
}
- final int expect = 5; // top level class, plus preceding examples
+ final int expect = 5 * 4; // top level class, plus preceding examples, 4 type variables each
}
@Target(ElementType.TYPE_PARAMETER)
-@interface Foo {}
+@interface Foo1 {}
@Target(ElementType.TYPE_PARAMETER)
-@interface Bar {}
+@interface Bar1 {}
@Target(ElementType.TYPE_PARAMETER)
-@interface Baz {}
+@interface Baz1 {}
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface Foo2 {}
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface Bar2 {}
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface Baz2 {}
+
+@Repeatable(ExpectedTypeParameterAnnotationsCollection.class)
+@interface ExpectedTypeParameterAnnotations {
+ public String typeParameterName();
+ public String[] annotations();
+}
+
+@interface ExpectedTypeParameterAnnotationsCollection {
+ public ExpectedTypeParameterAnnotations[] value();
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/types/BadSigTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/types/BadSigTest.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014, 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.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8037934
+ * @summary Javac generates invalid signatures for local types
+ * @run main BadSigTest
+ */
+
+public class BadSigTest {
+ void m(){
+ class Local1{}
+ class Local2 extends Local1{}
+ Local2.class.getTypeParameters();
+ }
+ public static void main(String[] args) {
+ new BadSigTest().m();
+ }
+}
diff -r c8b8cabfc922 -r c14269602ffd test/tools/javac/util/StringUtilsTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/util/StringUtilsTest.java Thu Jun 26 07:56:29 2014 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2013, 2014, 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.
+ *
+ * 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.
+ */
+
+/**
+ * @test
+ * @bug 8029800 8043186
+ * @summary Unit test StringUtils
+ * @run main StringUtilsTest
+ */
+
+import java.util.Locale;
+import java.util.Objects;
+import com.sun.tools.javac.util.StringUtils;
+
+public class StringUtilsTest {
+ public static void main(String... args) throws Exception {
+ new StringUtilsTest().run();
+ }
+
+ void run() throws Exception {
+ Locale.setDefault(new Locale("tr", "TR"));
+
+ //verify the properties of the default locale:
+ assertEquals("\u0131", "I".toLowerCase());
+ assertEquals("\u0130", "i".toUpperCase());
+
+ //verify the StringUtils.toLowerCase/toUpperCase do what they should:
+ assertEquals("i", StringUtils.toLowerCase("I"));
+ assertEquals("I", StringUtils.toUpperCase("i"));
+
+ //verify StringUtils.caseInsensitiveIndexOf works:
+ assertEquals(2, StringUtils.indexOfIgnoreCase(" lookFor", "lookfor"));
+ assertEquals(11, StringUtils.indexOfIgnoreCase(" lookFor LOOKfor", "lookfor", 11));
+ assertEquals(2, StringUtils.indexOfIgnoreCase("\u0130\u0130lookFor", "lookfor"));
+ }
+
+ void assertEquals(String expected, String actual) {
+ if (!Objects.equals(expected, actual)) {
+ throw new IllegalStateException("expected=" + expected + "; actual=" + actual);
+ }
+ }
+
+ void assertEquals(int expected, int actual) {
+ if (expected != actual) {
+ throw new IllegalStateException("expected=" + expected + "; actual=" + actual);
+ }
+ }
+}