Thu, 29 Oct 2015 17:21:12 -0700
Merge
.hgtags | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Fri Oct 16 12:19:45 2015 -0700 1.2 +++ b/.hgtags Thu Oct 29 17:21:12 2015 -0700 1.3 @@ -500,4 +500,14 @@ 1.4 fb2756fb330047dbbff0fa89b79e1d8d96146868 jdk8u71-b01 1.5 21306b94f23ef63cc3ac48a509d491187dadb0f6 jdk8u71-b02 1.6 43002f1aebfdaa64ad497f86c5f9a2f9b450b464 jdk8u71-b03 1.7 +531efb9ef9808eef700a0b4d9c3996090469ad6c jdk8u71-b04 1.8 +89deefc7b6bac551bb16fbb8740775cfd5f73998 jdk8u71-b05 1.9 +bc15decea6ad7b8b34b217af102f175a9a0d52c3 jdk8u71-b06 1.10 +1c93d260bf996e56d1e1f6d187aceadaa9a38d0c jdk8u72-b00 1.11 +aec633bcb3af5382013c6c25b435564aba5bc3d4 jdk8u72-b01 1.12 +dfb368f2498e5bfaac7cc7730b5e822999736cd7 jdk8u72-b02 1.13 +975709317923c28f0dfcf99d8456048f920d087e jdk8u72-b03 1.14 +106fb99e28d20623748c2c3a2120be37fcfac78f jdk8u72-b04 1.15 +5bb4ad0363a74265a931b24d0bb0f51b23f09060 jdk8u72-b05 1.16 +2e722fd7496556350510c5d3fc02c77377fd8bff jdk8u72-b06 1.17 90b497af2ba5329448da3a46a185687ae17f7098 jdk8u75-b00
2.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java Fri Oct 16 12:19:45 2015 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Thu Oct 29 17:21:12 2015 -0700 2.3 @@ -421,6 +421,14 @@ 2.4 && (tsym.flags() & COMPOUND) != 0; 2.5 } 2.6 2.7 + public boolean isIntersection() { 2.8 + return false; 2.9 + } 2.10 + 2.11 + public boolean isUnion() { 2.12 + return false; 2.13 + } 2.14 + 2.15 public boolean isInterface() { 2.16 return (tsym.flags() & INTERFACE) != 0; 2.17 } 2.18 @@ -970,6 +978,11 @@ 2.19 } 2.20 2.21 @Override 2.22 + public boolean isUnion() { 2.23 + return true; 2.24 + } 2.25 + 2.26 + @Override 2.27 public TypeKind getKind() { 2.28 return TypeKind.UNION; 2.29 } 2.30 @@ -1003,6 +1016,11 @@ 2.31 return interfaces_field.prepend(supertype_field); 2.32 } 2.33 2.34 + @Override 2.35 + public boolean isIntersection() { 2.36 + return true; 2.37 + } 2.38 + 2.39 public List<Type> getExplicitComponents() { 2.40 return allInterfaces ? 2.41 interfaces_field :
3.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Fri Oct 16 12:19:45 2015 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Thu Oct 29 17:21:12 2015 -0700 3.3 @@ -1539,8 +1539,8 @@ 3.4 } 3.5 } 3.6 3.7 - if (t.isCompound() || s.isCompound()) { 3.8 - return !t.isCompound() ? 3.9 + if (t.isIntersection() || s.isIntersection()) { 3.10 + return !t.isIntersection() ? 3.11 visitIntersectionType((IntersectionClassType)s.unannotatedType(), t, true) : 3.12 visitIntersectionType((IntersectionClassType)t.unannotatedType(), s, false); 3.13 } 3.14 @@ -2255,19 +2255,28 @@ 3.15 } 3.16 // </editor-fold> 3.17 3.18 - // <editor-fold defaultstate="collapsed" desc="makeCompoundType"> 3.19 + // <editor-fold defaultstate="collapsed" desc="makeIntersectionType"> 3.20 /** 3.21 - * Make a compound type from non-empty list of types. The list should be 3.22 - * ordered according to {@link Symbol#precedes(TypeSymbol,Types)}. 3.23 + * Make an intersection type from non-empty list of types. The list should be ordered according to 3.24 + * {@link TypeSymbol#precedes(TypeSymbol, Types)}. Note that this might cause a symbol completion. 3.25 + * Hence, this version of makeIntersectionType may not be called during a classfile read. 3.26 * 3.27 - * @param bounds the types from which the compound type is formed 3.28 - * @param supertype is objectType if all bounds are interfaces, 3.29 - * null otherwise. 3.30 + * @param bounds the types from which the intersection type is formed 3.31 */ 3.32 - public Type makeCompoundType(List<Type> bounds) { 3.33 - return makeCompoundType(bounds, bounds.head.tsym.isInterface()); 3.34 + public IntersectionClassType makeIntersectionType(List<Type> bounds) { 3.35 + return makeIntersectionType(bounds, bounds.head.tsym.isInterface()); 3.36 } 3.37 - public Type makeCompoundType(List<Type> bounds, boolean allInterfaces) { 3.38 + 3.39 + /** 3.40 + * Make an intersection type from non-empty list of types. The list should be ordered according to 3.41 + * {@link TypeSymbol#precedes(TypeSymbol, Types)}. This does not cause symbol completion as 3.42 + * an extra parameter indicates as to whether all bounds are interfaces - in which case the 3.43 + * supertype is implicitly assumed to be 'Object'. 3.44 + * 3.45 + * @param bounds the types from which the intersection type is formed 3.46 + * @param allInterfaces are all bounds interface types? 3.47 + */ 3.48 + public IntersectionClassType makeIntersectionType(List<Type> bounds, boolean allInterfaces) { 3.49 Assert.check(bounds.nonEmpty()); 3.50 Type firstExplicitBound = bounds.head; 3.51 if (allInterfaces) { 3.52 @@ -2280,23 +2289,24 @@ 3.53 : names.empty, 3.54 null, 3.55 syms.noSymbol); 3.56 - bc.type = new IntersectionClassType(bounds, bc, allInterfaces); 3.57 + IntersectionClassType intersectionType = new IntersectionClassType(bounds, bc, allInterfaces); 3.58 + bc.type = intersectionType; 3.59 bc.erasure_field = (bounds.head.hasTag(TYPEVAR)) ? 3.60 syms.objectType : // error condition, recover 3.61 erasure(firstExplicitBound); 3.62 bc.members_field = new Scope(bc); 3.63 - return bc.type; 3.64 + return intersectionType; 3.65 } 3.66 3.67 /** 3.68 - * A convenience wrapper for {@link #makeCompoundType(List)}; the 3.69 + * A convenience wrapper for {@link #makeIntersectionType(List)}; the 3.70 * arguments are converted to a list and passed to the other 3.71 * method. Note that this might cause a symbol completion. 3.72 - * Hence, this version of makeCompoundType may not be called 3.73 + * Hence, this version of makeIntersectionType may not be called 3.74 * during a classfile read. 3.75 */ 3.76 - public Type makeCompoundType(Type bound1, Type bound2) { 3.77 - return makeCompoundType(List.of(bound1, bound2)); 3.78 + public Type makeIntersectionType(Type bound1, Type bound2) { 3.79 + return makeIntersectionType(List.of(bound1, bound2)); 3.80 } 3.81 // </editor-fold> 3.82 3.83 @@ -2436,7 +2446,7 @@ 3.84 private final UnaryVisitor<List<Type>> directSupertypes = new UnaryVisitor<List<Type>>() { 3.85 3.86 public List<Type> visitType(final Type type, final Void ignored) { 3.87 - if (!type.isCompound()) { 3.88 + if (!type.isIntersection()) { 3.89 final Type sup = supertype(type); 3.90 return (sup == Type.noType || sup == type || sup == null) 3.91 ? interfaces(type) 3.92 @@ -2490,30 +2500,32 @@ 3.93 3.94 // <editor-fold defaultstate="collapsed" desc="setBounds"> 3.95 /** 3.96 - * Set the bounds field of the given type variable to reflect a 3.97 - * (possibly multiple) list of bounds. 3.98 - * @param t a type variable 3.99 - * @param bounds the bounds, must be nonempty 3.100 - * @param supertype is objectType if all bounds are interfaces, 3.101 - * null otherwise. 3.102 + * Same as {@link Types#setBounds(TypeVar, List, boolean)}, except that third parameter is computed directly, 3.103 + * as follows: if all all bounds are interface types, the computed supertype is Object,otherwise 3.104 + * the supertype is simply left null (in this case, the supertype is assumed to be the head of 3.105 + * the bound list passed as second argument). Note that this check might cause a symbol completion. 3.106 + * Hence, this version of setBounds may not be called during a classfile read. 3.107 + * 3.108 + * @param t a type variable 3.109 + * @param bounds the bounds, must be nonempty 3.110 */ 3.111 public void setBounds(TypeVar t, List<Type> bounds) { 3.112 setBounds(t, bounds, bounds.head.tsym.isInterface()); 3.113 } 3.114 3.115 /** 3.116 - * Same as {@link #setBounds(Type.TypeVar,List,Type)}, except that 3.117 - * third parameter is computed directly, as follows: if all 3.118 - * all bounds are interface types, the computed supertype is Object, 3.119 - * otherwise the supertype is simply left null (in this case, the supertype 3.120 - * is assumed to be the head of the bound list passed as second argument). 3.121 - * Note that this check might cause a symbol completion. Hence, this version of 3.122 - * setBounds may not be called during a classfile read. 3.123 + * Set the bounds field of the given type variable to reflect a (possibly multiple) list of bounds. 3.124 + * This does not cause symbol completion as an extra parameter indicates as to whether all bounds 3.125 + * are interfaces - in which case the supertype is implicitly assumed to be 'Object'. 3.126 + * 3.127 + * @param t a type variable 3.128 + * @param bounds the bounds, must be nonempty 3.129 + * @param allInterfaces are all bounds interface types? 3.130 */ 3.131 public void setBounds(TypeVar t, List<Type> bounds, boolean allInterfaces) { 3.132 t.bound = bounds.tail.isEmpty() ? 3.133 bounds.head : 3.134 - makeCompoundType(bounds, allInterfaces); 3.135 + makeIntersectionType(bounds, allInterfaces); 3.136 t.rank_field = -1; 3.137 } 3.138 // </editor-fold> 3.139 @@ -3063,7 +3075,7 @@ 3.140 if (st == supertype(t) && is == interfaces(t)) 3.141 return t; 3.142 else 3.143 - return makeCompoundType(is.prepend(st)); 3.144 + return makeIntersectionType(is.prepend(st)); 3.145 } 3.146 } 3.147 3.148 @@ -3566,7 +3578,7 @@ 3.149 else if (compound.tail.isEmpty()) 3.150 return compound.head; 3.151 else 3.152 - return makeCompoundType(compound); 3.153 + return makeIntersectionType(compound); 3.154 } 3.155 3.156 /** 3.157 @@ -3744,8 +3756,8 @@ 3.158 synchronized (this) { 3.159 if (arraySuperType == null) { 3.160 // JLS 10.8: all arrays implement Cloneable and Serializable. 3.161 - arraySuperType = makeCompoundType(List.of(syms.serializableType, 3.162 - syms.cloneableType), true); 3.163 + arraySuperType = makeIntersectionType(List.of(syms.serializableType, 3.164 + syms.cloneableType), true); 3.165 } 3.166 } 3.167 } 3.168 @@ -3811,7 +3823,7 @@ 3.169 return glbFlattened(union(bounds, lowers), errT); 3.170 } 3.171 } 3.172 - return makeCompoundType(bounds); 3.173 + return makeIntersectionType(bounds); 3.174 } 3.175 // </editor-fold> 3.176
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Oct 16 12:19:45 2015 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Oct 29 17:21:12 2015 -0700 4.3 @@ -2434,7 +2434,7 @@ 4.4 4.5 @Override 4.6 public Type visitClassType(ClassType t, DiagnosticPosition pos) { 4.7 - return t.isCompound() ? 4.8 + return t.isIntersection() ? 4.9 visitIntersectionClassType((IntersectionClassType)t, pos) : t; 4.10 } 4.11 4.12 @@ -2465,8 +2465,7 @@ 4.13 } 4.14 supertypes.append(i.tsym.type); 4.15 } 4.16 - IntersectionClassType notionalIntf = 4.17 - (IntersectionClassType)types.makeCompoundType(supertypes.toList()); 4.18 + IntersectionClassType notionalIntf = types.makeIntersectionType(supertypes.toList()); 4.19 notionalIntf.allparams_field = targs.toList(); 4.20 notionalIntf.tsym.flags_field |= INTERFACE; 4.21 return notionalIntf.tsym; 4.22 @@ -4032,7 +4031,7 @@ 4.23 } else if (bounds.length() == 1) { 4.24 return bounds.head.type; 4.25 } else { 4.26 - Type owntype = types.makeCompoundType(TreeInfo.types(bounds)); 4.27 + Type owntype = types.makeIntersectionType(TreeInfo.types(bounds)); 4.28 // ... the variable's bound is a class type flagged COMPOUND 4.29 // (see comment for TypeVar.bound). 4.30 // In this case, generate a class tree that represents the
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Oct 16 12:19:45 2015 -0700 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Oct 29 17:21:12 2015 -0700 5.3 @@ -1813,7 +1813,7 @@ 5.4 Type t1, 5.5 Type t2) { 5.6 return checkCompatibleAbstracts(pos, t1, t2, 5.7 - types.makeCompoundType(t1, t2)); 5.8 + types.makeIntersectionType(t1, t2)); 5.9 } 5.10 5.11 public boolean checkCompatibleAbstracts(DiagnosticPosition pos,
6.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Oct 16 12:19:45 2015 -0700 6.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Oct 29 17:21:12 2015 -0700 6.3 @@ -373,7 +373,7 @@ 6.4 List<Type> upperBounds = uv.getBounds(InferenceBound.UPPER); 6.5 if (Type.containsAny(upperBounds, vars)) { 6.6 TypeSymbol fresh_tvar = new TypeVariableSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner); 6.7 - fresh_tvar.type = new TypeVar(fresh_tvar, types.makeCompoundType(uv.getBounds(InferenceBound.UPPER)), null); 6.8 + fresh_tvar.type = new TypeVar(fresh_tvar, types.makeIntersectionType(uv.getBounds(InferenceBound.UPPER)), null); 6.9 todo.append(uv); 6.10 uv.inst = fresh_tvar.type; 6.11 } else if (upperBounds.nonEmpty()) {
7.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Fri Oct 16 12:19:45 2015 -0700 7.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Thu Oct 29 17:21:12 2015 -0700 7.3 @@ -1179,12 +1179,14 @@ 7.4 @Override 7.5 public void visitClassDef(JCClassDecl tree) { 7.6 List<Frame> prevStack = frameStack; 7.7 + int prevLambdaCount = lambdaCount; 7.8 SyntheticMethodNameCounter prevSyntheticMethodNameCounts = 7.9 syntheticMethodNameCounts; 7.10 Map<ClassSymbol, Symbol> prevClinits = clinits; 7.11 DiagnosticSource prevSource = log.currentSource(); 7.12 try { 7.13 log.useSource(tree.sym.sourcefile); 7.14 + lambdaCount = 0; 7.15 syntheticMethodNameCounts = new SyntheticMethodNameCounter(); 7.16 prevClinits = new HashMap<ClassSymbol, Symbol>(); 7.17 if (tree.sym.owner.kind == MTH) { 7.18 @@ -1211,6 +1213,7 @@ 7.19 finally { 7.20 log.useSource(prevSource.getFile()); 7.21 frameStack = prevStack; 7.22 + lambdaCount = prevLambdaCount; 7.23 syntheticMethodNameCounts = prevSyntheticMethodNameCounts; 7.24 clinits = prevClinits; 7.25 }
8.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Fri Oct 16 12:19:45 2015 -0700 8.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Oct 29 17:21:12 2015 -0700 8.3 @@ -750,7 +750,7 @@ 8.4 Type originalTarget = tree.type; 8.5 tree.type = erasure(tree.type); 8.6 tree.expr = translate(tree.expr, tree.type); 8.7 - if (originalTarget.isCompound()) { 8.8 + if (originalTarget.isIntersection()) { 8.9 Type.IntersectionClassType ict = (Type.IntersectionClassType)originalTarget; 8.10 for (Type c : ict.getExplicitComponents()) { 8.11 Type ec = erasure(c);
9.1 --- a/src/share/classes/com/sun/tools/javac/resources/javac.properties Fri Oct 16 12:19:45 2015 -0700 9.2 +++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties Thu Oct 29 17:21:12 2015 -0700 9.3 @@ -232,9 +232,9 @@ 9.4 9.5 javac.msg.bug=\ 9.6 An exception has occurred in the compiler ({0}). \ 9.7 -Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) \ 9.8 -after checking the database for duplicates. \ 9.9 -Include your program and the following diagnostic in your report. Thank you. 9.10 +Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) \ 9.11 +after checking the Bug Database (http://bugs.java.com) for duplicates. \ 9.12 +Include your program and the following diagnostic in your report. Thank you. 9.13 9.14 javac.msg.io=\ 9.15 \n\nAn input/output error occurred.\n\
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/tools/javac/lambda/lambdaNaming/TestNonSerializableLambdaNameStability.java Thu Oct 29 17:21:12 2015 -0700 10.3 @@ -0,0 +1,157 @@ 10.4 +/* 10.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.23 + * or visit www.oracle.com if you need additional information or have any 10.24 + * questions. 10.25 + */ 10.26 + 10.27 +/* 10.28 + * @test 10.29 + * @bug 8067422 10.30 + * @summary Check that the lambda names are not unnecessarily unstable 10.31 + * @run main TestNonSerializableLambdaNameStability 10.32 + */ 10.33 + 10.34 +import com.sun.tools.classfile.ClassFile; 10.35 +import com.sun.tools.classfile.Method; 10.36 + 10.37 +import java.io.ByteArrayInputStream; 10.38 +import java.io.ByteArrayOutputStream; 10.39 +import java.io.IOException; 10.40 +import java.io.InputStream; 10.41 +import java.io.OutputStream; 10.42 +import java.net.URI; 10.43 +import java.net.URISyntaxException; 10.44 +import java.util.ArrayList; 10.45 +import java.util.HashMap; 10.46 +import java.util.List; 10.47 +import java.util.Map; 10.48 + 10.49 +import javax.tools.FileObject; 10.50 +import javax.tools.ForwardingJavaFileManager; 10.51 +import javax.tools.JavaCompiler; 10.52 +import javax.tools.JavaFileManager; 10.53 +import javax.tools.JavaFileObject; 10.54 +import javax.tools.JavaFileObject.Kind; 10.55 +import javax.tools.SimpleJavaFileObject; 10.56 +import javax.tools.ToolProvider; 10.57 + 10.58 +public class TestNonSerializableLambdaNameStability { 10.59 + 10.60 + public static void main(String... args) throws Exception { 10.61 + new TestNonSerializableLambdaNameStability().run(); 10.62 + } 10.63 + 10.64 + String lambdaSource = "public class L%d {\n" + 10.65 + " public static class A {\n" + 10.66 + " private Runnable r = () -> { };\n" + 10.67 + " }\n" + 10.68 + " public static class B {\n" + 10.69 + " private Runnable r = () -> { };\n" + 10.70 + " }\n" + 10.71 + " private Runnable r = () -> { };\n" + 10.72 + "}\n"; 10.73 + 10.74 + String expectedLambdaMethodName = "lambda$new$0"; 10.75 + 10.76 + void run() throws Exception { 10.77 + List<JavaFileObject> sources = new ArrayList<>(); 10.78 + 10.79 + for (int i = 0; i < 3; i++) { 10.80 + sources.add(new SourceJavaFileObject("L" + i, String.format(lambdaSource, i))); 10.81 + } 10.82 + 10.83 + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 10.84 + 10.85 + try (MemoryFileManager fm = new MemoryFileManager(compiler.getStandardFileManager(null, null, null))) { 10.86 + if (!compiler.getTask(null, fm, null, null, null, sources).call()) { 10.87 + throw new AssertionError("Compilation failed!"); 10.88 + } 10.89 + 10.90 + for (String file : fm.name2Content.keySet()) { 10.91 + byte[] fileBytes = fm.name2Content.get(file); 10.92 + try (InputStream in = new ByteArrayInputStream(fileBytes)) { 10.93 + boolean foundLambdaMethod = false; 10.94 + ClassFile cf = ClassFile.read(in); 10.95 + StringBuilder seenMethods = new StringBuilder(); 10.96 + String sep = ""; 10.97 + for (Method m : cf.methods) { 10.98 + String methodName = m.getName(cf.constant_pool); 10.99 + if (expectedLambdaMethodName.equals(methodName)) { 10.100 + foundLambdaMethod = true; 10.101 + break; 10.102 + } 10.103 + seenMethods.append(sep); 10.104 + seenMethods.append(methodName); 10.105 + sep = ", "; 10.106 + } 10.107 + 10.108 + if (!foundLambdaMethod) { 10.109 + throw new AbstractMethodError("Did not find the lambda method, " + 10.110 + "found methods: " + seenMethods.toString()); 10.111 + } 10.112 + } 10.113 + } 10.114 + } 10.115 + } 10.116 + 10.117 + class MemoryFileManager extends ForwardingJavaFileManager<JavaFileManager> { 10.118 + 10.119 + final Map<String, byte[]> name2Content = new HashMap<>(); 10.120 + 10.121 + public MemoryFileManager(JavaFileManager fileManager) { 10.122 + super(fileManager); 10.123 + } 10.124 + 10.125 + @Override 10.126 + public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException { 10.127 + try { 10.128 + return new SimpleJavaFileObject(new URI("mem://" + className.replace('.', '/') + kind.extension), kind) { 10.129 + @Override public OutputStream openOutputStream() throws IOException { 10.130 + return new ByteArrayOutputStream() { 10.131 + @Override public void close() throws IOException { 10.132 + super.close(); 10.133 + name2Content.put(className, toByteArray()); 10.134 + } 10.135 + }; 10.136 + } 10.137 + }; 10.138 + } catch (URISyntaxException ex) { 10.139 + throw new AssertionError(ex); 10.140 + } 10.141 + } 10.142 + 10.143 + } 10.144 + 10.145 + class SourceJavaFileObject extends SimpleJavaFileObject { 10.146 + 10.147 + private final String code; 10.148 + 10.149 + public SourceJavaFileObject(String name, String code) throws URISyntaxException { 10.150 + super(new URI("mem:///" + name + ".java"), Kind.SOURCE); 10.151 + this.code = code; 10.152 + } 10.153 + 10.154 + @Override 10.155 + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { 10.156 + return code; 10.157 + } 10.158 + 10.159 + } 10.160 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/tools/javac/multicatch/8071291/T8071291.java Thu Oct 29 17:21:12 2015 -0700 11.3 @@ -0,0 +1,49 @@ 11.4 +/* 11.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. 11.11 + * 11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 + * version 2 for more details (a copy is included in the LICENSE file that 11.16 + * accompanied this code). 11.17 + * 11.18 + * You should have received a copy of the GNU General Public License version 11.19 + * 2 along with this work; if not, write to the Free Software Foundation, 11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 + * 11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.23 + * or visit www.oracle.com if you need additional information or have any 11.24 + * questions. 11.25 + */ 11.26 + 11.27 +/* 11.28 + * @test 11.29 + * @bug 8071291 11.30 + * @summary Compiler crashes trying to cast UnionType to IntersectionClassType 11.31 + * @compile T8071291.java 11.32 + */ 11.33 + 11.34 +class T8071291 { 11.35 + 11.36 + interface A { } 11.37 + class Exception1 extends Exception implements A { } 11.38 + class Exception2 extends Exception implements A { } 11.39 + 11.40 + void test(boolean cond) { 11.41 + try { 11.42 + if (cond) { 11.43 + throw new Exception1(); 11.44 + } else { 11.45 + throw new Exception2(); 11.46 + } 11.47 + } 11.48 + catch (Exception1|Exception2 x) { 11.49 + if (x instanceof Exception1) { } 11.50 + } 11.51 + } 11.52 +}