Mercurial > hg > release > icedtea8-forest-3.0 > langtools
changeset 3130:74cf0ebe274d
Merge
author | asaha |
---|---|
date | Wed, 02 Dec 2015 23:07:58 -0800 |
parents | ae9d8609f760 (diff) 5ceff8f21ebd (current diff) |
children | cf2fdc2c96b1 02c1a2a0c189 |
files | .hgtags src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java |
diffstat | 11 files changed, 152 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Tue Dec 01 22:55:31 2015 -0800 +++ b/.hgtags Wed Dec 02 23:07:58 2015 -0800 @@ -496,7 +496,32 @@ 8063e4ac4caabe1756f8393859ab56da3bb29122 jdk8u66-b15 01e7f91d993b341986f574d0eb3fbfe3d7cae68e jdk8u66-b16 ad3f528335b4c609eee7227d150c9a0a39b1dd73 jdk8u66-b17 +ee701de614ad0c5f4bf3a553942909a54084c458 jdk8u66-b18 f55af75598d85f45f779f3e632152a067fb7efbc jdk8u66-b31 accc23223f7980daf5c22c17b951ecf729a904fa jdk8u66-b32 e7db5523c835b47eae3cfac6f3d0bd3647a12118 jdk8u66-b33 0d7fcabf56edc9580555b847ffe0e3f88f09fbfb jdk8u66-b34 +aaad025819b721f7f291048a07cd1c144319b68d jdk8u71-b00 +fb2756fb330047dbbff0fa89b79e1d8d96146868 jdk8u71-b01 +21306b94f23ef63cc3ac48a509d491187dadb0f6 jdk8u71-b02 +43002f1aebfdaa64ad497f86c5f9a2f9b450b464 jdk8u71-b03 +531efb9ef9808eef700a0b4d9c3996090469ad6c jdk8u71-b04 +89deefc7b6bac551bb16fbb8740775cfd5f73998 jdk8u71-b05 +bc15decea6ad7b8b34b217af102f175a9a0d52c3 jdk8u71-b06 +6462f92dadf2e5b7ac6fc35f7b38a5018108fd4d jdk8u71-b07 +ef48693aa6ab6356a46830f3f127d41394b79224 jdk8u71-b08 +8089203f9ae281143388d3d6bbe448ef94c32433 jdk8u71-b09 +f01e8d723f60fb5cae3e64db771590d2219fa1b9 jdk8u71-b10 +69f2b3ae357a2a85c3f6e9c74e13e42eb6acd899 jdk8u71-b11 +1c93d260bf996e56d1e1f6d187aceadaa9a38d0c jdk8u72-b00 +aec633bcb3af5382013c6c25b435564aba5bc3d4 jdk8u72-b01 +dfb368f2498e5bfaac7cc7730b5e822999736cd7 jdk8u72-b02 +975709317923c28f0dfcf99d8456048f920d087e jdk8u72-b03 +106fb99e28d20623748c2c3a2120be37fcfac78f jdk8u72-b04 +5bb4ad0363a74265a931b24d0bb0f51b23f09060 jdk8u72-b05 +2e722fd7496556350510c5d3fc02c77377fd8bff jdk8u72-b06 +34d01f3892f5d7408926d5b29da0bcfdc8238f5b jdk8u72-b07 +98179963e9332fd10e8c369e5e50dfe5df280a18 jdk8u72-b08 +a9ec52fb3bc762ccca9baeda84333fdf8465f707 jdk8u72-b09 +96744607e4b9fb85c985e70ba07a803e8792c576 jdk8u72-b10 +6840ff8b3db5e47576893fb0fa940202a50f2e12 jdk8u72-b11
--- a/src/share/classes/com/sun/tools/javac/code/Type.java Tue Dec 01 22:55:31 2015 -0800 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Wed Dec 02 23:07:58 2015 -0800 @@ -421,6 +421,14 @@ && (tsym.flags() & COMPOUND) != 0; } + public boolean isIntersection() { + return false; + } + + public boolean isUnion() { + return false; + } + public boolean isInterface() { return (tsym.flags() & INTERFACE) != 0; } @@ -970,6 +978,11 @@ } @Override + public boolean isUnion() { + return true; + } + + @Override public TypeKind getKind() { return TypeKind.UNION; } @@ -1003,6 +1016,11 @@ return interfaces_field.prepend(supertype_field); } + @Override + public boolean isIntersection() { + return true; + } + public List<Type> getExplicitComponents() { return allInterfaces ? interfaces_field :
--- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue Dec 01 22:55:31 2015 -0800 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Wed Dec 02 23:07:58 2015 -0800 @@ -1539,8 +1539,8 @@ } } - if (t.isCompound() || s.isCompound()) { - return !t.isCompound() ? + if (t.isIntersection() || s.isIntersection()) { + return !t.isIntersection() ? visitIntersectionType((IntersectionClassType)s.unannotatedType(), t, true) : visitIntersectionType((IntersectionClassType)t.unannotatedType(), s, false); } @@ -2255,19 +2255,28 @@ } // </editor-fold> - // <editor-fold defaultstate="collapsed" desc="makeCompoundType"> + // <editor-fold defaultstate="collapsed" desc="makeIntersectionType"> /** - * Make a compound type from non-empty list of types. The list should be - * ordered according to {@link Symbol#precedes(TypeSymbol,Types)}. + * Make an intersection type from non-empty list of types. The list should be ordered according to + * {@link TypeSymbol#precedes(TypeSymbol, Types)}. Note that this might cause a symbol completion. + * Hence, this version of makeIntersectionType may not be called during a classfile read. * - * @param bounds the types from which the compound type is formed - * @param supertype is objectType if all bounds are interfaces, - * null otherwise. + * @param bounds the types from which the intersection type is formed */ - public Type makeCompoundType(List<Type> bounds) { - return makeCompoundType(bounds, bounds.head.tsym.isInterface()); + public IntersectionClassType makeIntersectionType(List<Type> bounds) { + return makeIntersectionType(bounds, bounds.head.tsym.isInterface()); } - public Type makeCompoundType(List<Type> bounds, boolean allInterfaces) { + + /** + * Make an intersection type from non-empty list of types. The list should be ordered according to + * {@link TypeSymbol#precedes(TypeSymbol, Types)}. This does not cause symbol completion as + * an extra parameter indicates as to whether all bounds are interfaces - in which case the + * supertype is implicitly assumed to be 'Object'. + * + * @param bounds the types from which the intersection type is formed + * @param allInterfaces are all bounds interface types? + */ + public IntersectionClassType makeIntersectionType(List<Type> bounds, boolean allInterfaces) { Assert.check(bounds.nonEmpty()); Type firstExplicitBound = bounds.head; if (allInterfaces) { @@ -2280,23 +2289,24 @@ : names.empty, null, syms.noSymbol); - bc.type = new IntersectionClassType(bounds, bc, allInterfaces); + IntersectionClassType intersectionType = new IntersectionClassType(bounds, bc, allInterfaces); + bc.type = intersectionType; bc.erasure_field = (bounds.head.hasTag(TYPEVAR)) ? syms.objectType : // error condition, recover erasure(firstExplicitBound); bc.members_field = new Scope(bc); - return bc.type; + return intersectionType; } /** - * A convenience wrapper for {@link #makeCompoundType(List)}; the + * A convenience wrapper for {@link #makeIntersectionType(List)}; the * arguments are converted to a list and passed to the other * method. Note that this might cause a symbol completion. - * Hence, this version of makeCompoundType may not be called + * Hence, this version of makeIntersectionType may not be called * during a classfile read. */ - public Type makeCompoundType(Type bound1, Type bound2) { - return makeCompoundType(List.of(bound1, bound2)); + public Type makeIntersectionType(Type bound1, Type bound2) { + return makeIntersectionType(List.of(bound1, bound2)); } // </editor-fold> @@ -2436,7 +2446,7 @@ private final UnaryVisitor<List<Type>> directSupertypes = new UnaryVisitor<List<Type>>() { public List<Type> visitType(final Type type, final Void ignored) { - if (!type.isCompound()) { + if (!type.isIntersection()) { final Type sup = supertype(type); return (sup == Type.noType || sup == type || sup == null) ? interfaces(type) @@ -2490,30 +2500,32 @@ // <editor-fold defaultstate="collapsed" desc="setBounds"> /** - * Set the bounds field of the given type variable to reflect a - * (possibly multiple) list of bounds. - * @param t a type variable - * @param bounds the bounds, must be nonempty - * @param supertype is objectType if all bounds are interfaces, - * null otherwise. + * Same as {@link Types#setBounds(TypeVar, List, boolean)}, except that third parameter is computed directly, + * as follows: if all all bounds are interface types, the computed supertype is Object,otherwise + * the supertype is simply left null (in this case, the supertype is assumed to be the head of + * the bound list passed as second argument). Note that this check might cause a symbol completion. + * Hence, this version of setBounds may not be called during a classfile read. + * + * @param t a type variable + * @param bounds the bounds, must be nonempty */ public void setBounds(TypeVar t, List<Type> bounds) { setBounds(t, bounds, bounds.head.tsym.isInterface()); } /** - * Same as {@link #setBounds(Type.TypeVar,List,Type)}, except that - * third parameter is computed directly, as follows: if all - * all bounds are interface types, the computed supertype is Object, - * otherwise the supertype is simply left null (in this case, the supertype - * is assumed to be the head of the bound list passed as second argument). - * Note that this check might cause a symbol completion. Hence, this version of - * setBounds may not be called during a classfile read. + * Set the bounds field of the given type variable to reflect a (possibly multiple) list of bounds. + * This does not cause symbol completion as an extra parameter indicates as to whether all bounds + * are interfaces - in which case the supertype is implicitly assumed to be 'Object'. + * + * @param t a type variable + * @param bounds the bounds, must be nonempty + * @param allInterfaces are all bounds interface types? */ public void setBounds(TypeVar t, List<Type> bounds, boolean allInterfaces) { t.bound = bounds.tail.isEmpty() ? bounds.head : - makeCompoundType(bounds, allInterfaces); + makeIntersectionType(bounds, allInterfaces); t.rank_field = -1; } // </editor-fold> @@ -3063,7 +3075,7 @@ if (st == supertype(t) && is == interfaces(t)) return t; else - return makeCompoundType(is.prepend(st)); + return makeIntersectionType(is.prepend(st)); } } @@ -3566,7 +3578,7 @@ else if (compound.tail.isEmpty()) return compound.head; else - return makeCompoundType(compound); + return makeIntersectionType(compound); } /** @@ -3744,8 +3756,8 @@ synchronized (this) { if (arraySuperType == null) { // JLS 10.8: all arrays implement Cloneable and Serializable. - arraySuperType = makeCompoundType(List.of(syms.serializableType, - syms.cloneableType), true); + arraySuperType = makeIntersectionType(List.of(syms.serializableType, + syms.cloneableType), true); } } } @@ -3811,7 +3823,7 @@ return glbFlattened(union(bounds, lowers), errT); } } - return makeCompoundType(bounds); + return makeIntersectionType(bounds); } // </editor-fold>
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Dec 01 22:55:31 2015 -0800 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Dec 02 23:07:58 2015 -0800 @@ -2434,7 +2434,7 @@ @Override public Type visitClassType(ClassType t, DiagnosticPosition pos) { - return t.isCompound() ? + return t.isIntersection() ? visitIntersectionClassType((IntersectionClassType)t, pos) : t; } @@ -2465,8 +2465,7 @@ } supertypes.append(i.tsym.type); } - IntersectionClassType notionalIntf = - (IntersectionClassType)types.makeCompoundType(supertypes.toList()); + IntersectionClassType notionalIntf = types.makeIntersectionType(supertypes.toList()); notionalIntf.allparams_field = targs.toList(); notionalIntf.tsym.flags_field |= INTERFACE; return notionalIntf.tsym; @@ -4032,7 +4031,7 @@ } else if (bounds.length() == 1) { return bounds.head.type; } else { - Type owntype = types.makeCompoundType(TreeInfo.types(bounds)); + Type owntype = types.makeIntersectionType(TreeInfo.types(bounds)); // ... the variable's bound is a class type flagged COMPOUND // (see comment for TypeVar.bound). // In this case, generate a class tree that represents the
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Dec 01 22:55:31 2015 -0800 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Dec 02 23:07:58 2015 -0800 @@ -1813,7 +1813,7 @@ Type t1, Type t2) { return checkCompatibleAbstracts(pos, t1, t2, - types.makeCompoundType(t1, t2)); + types.makeIntersectionType(t1, t2)); } public boolean checkCompatibleAbstracts(DiagnosticPosition pos,
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Dec 01 22:55:31 2015 -0800 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Dec 02 23:07:58 2015 -0800 @@ -373,7 +373,7 @@ List<Type> upperBounds = uv.getBounds(InferenceBound.UPPER); if (Type.containsAny(upperBounds, vars)) { TypeSymbol fresh_tvar = new TypeVariableSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner); - fresh_tvar.type = new TypeVar(fresh_tvar, types.makeCompoundType(uv.getBounds(InferenceBound.UPPER)), null); + fresh_tvar.type = new TypeVar(fresh_tvar, types.makeIntersectionType(uv.getBounds(InferenceBound.UPPER)), null); todo.append(uv); uv.inst = fresh_tvar.type; } else if (upperBounds.nonEmpty()) {
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Dec 01 22:55:31 2015 -0800 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Wed Dec 02 23:07:58 2015 -0800 @@ -750,7 +750,7 @@ Type originalTarget = tree.type; tree.type = erasure(tree.type); tree.expr = translate(tree.expr, tree.type); - if (originalTarget.isCompound()) { + if (originalTarget.isIntersection()) { Type.IntersectionClassType ict = (Type.IntersectionClassType)originalTarget; for (Type c : ict.getExplicitComponents()) { Type ec = erasure(c);
--- a/src/share/classes/com/sun/tools/javac/resources/javac.properties Tue Dec 01 22:55:31 2015 -0800 +++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties Wed Dec 02 23:07:58 2015 -0800 @@ -232,9 +232,9 @@ javac.msg.bug=\ An exception has occurred in the compiler ({0}). \ -Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) \ -after checking the database for duplicates. \ -Include your program and the following diagnostic in your report. Thank you. +Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) \ +after checking the Bug Database (http://bugs.java.com) for duplicates. \ +Include your program and the following diagnostic in your report. Thank you. javac.msg.io=\ \n\nAn input/output error occurred.\n\
--- a/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Tue Dec 01 22:55:31 2015 -0800 +++ b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Wed Dec 02 23:07:58 2015 -0800 @@ -133,7 +133,7 @@ javac.msg.usage.nonstandard.footer=\u3053\u308C\u3089\u306F\u975E\u6A19\u6E96\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u3042\u308A\u4E88\u544A\u306A\u3057\u306B\u5909\u66F4\u3055\u308C\u308B\u3053\u3068\u304C\u3042\u308A\u307E\u3059\u3002 -javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java Bug Database (http://bugreport.java.com/bugreport/)\u3067bug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 +javac.msg.bug=\u30B3\u30F3\u30D1\u30A4\u30E9\u3067\u4F8B\u5916\u304C\u767A\u751F\u3057\u307E\u3057\u305F({0})\u3002Bug Database (http://bugs.java.com)\u3067\u91CD\u8907\u304C\u306A\u3044\u304B\u3092\u3054\u78BA\u8A8D\u306E\u3046\u3048\u3001Java bug\u30EC\u30DD\u30FC\u30C8\u30FB\u30DA\u30FC\u30B8(http://bugreport.java.com)\u3067Java\u30B3\u30F3\u30D1\u30A4\u30E9\u306B\u5BFE\u3059\u308Bbug\u306E\u767B\u9332\u3092\u304A\u9858\u3044\u3044\u305F\u3057\u307E\u3059\u3002\u30EC\u30DD\u30FC\u30C8\u306B\u306F\u3001\u305D\u306E\u30D7\u30ED\u30B0\u30E9\u30E0\u3068\u4E0B\u8A18\u306E\u8A3A\u65AD\u5185\u5BB9\u3092\u542B\u3081\u3066\u304F\u3060\u3055\u3044\u3002\u3054\u5354\u529B\u3042\u308A\u304C\u3068\u3046\u3054\u3056\u3044\u307E\u3059\u3002 javac.msg.io=\n\n\u5165\u51FA\u529B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\n\u8A73\u7D30\u306F\u6B21\u306E\u30B9\u30BF\u30C3\u30AF\u30FB\u30C8\u30EC\u30FC\u30B9\u3067\u8ABF\u67FB\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n
--- a/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties Tue Dec 01 22:55:31 2015 -0800 +++ b/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties Wed Dec 02 23:07:58 2015 -0800 @@ -133,7 +133,7 @@ javac.msg.usage.nonstandard.footer=\u8FD9\u4E9B\u9009\u9879\u90FD\u662F\u975E\u6807\u51C6\u9009\u9879, \u5982\u6709\u66F4\u6539, \u6055\u4E0D\u53E6\u884C\u901A\u77E5\u3002 -javac.msg.bug=\u7F16\u8BD1\u5668 ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002\u5982\u679C\u5728 Java Bug Database (http://bugreport.java.com/bugreport/) \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u5728\u8BE5\u6570\u636E\u5E93\u4E2D\u5EFA\u7ACB Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 +javac.msg.bug=\u7F16\u8BD1\u5668 ({0}) \u4E2D\u51FA\u73B0\u5F02\u5E38\u9519\u8BEF\u3002\u5982\u679C\u5728 Bug Database (http://bugs.java.com) \u4E2D\u6CA1\u6709\u627E\u5230\u8BE5\u9519\u8BEF, \u8BF7\u901A\u8FC7 Java Bug \u62A5\u544A\u9875 (http://bugreport.java.com) \u5EFA\u7ACB\u8BE5 Java \u7F16\u8BD1\u5668 Bug\u3002\u8BF7\u5728\u62A5\u544A\u4E2D\u9644\u4E0A\u60A8\u7684\u7A0B\u5E8F\u548C\u4EE5\u4E0B\u8BCA\u65AD\u4FE1\u606F\u3002\u8C22\u8C22\u3002 javac.msg.io=\n\n\u53D1\u751F\u8F93\u5165/\u8F93\u51FA\u9519\u8BEF\u3002\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u53C2\u9605\u4EE5\u4E0B\u5806\u6808\u8DDF\u8E2A\u3002\n
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/multicatch/8071291/T8071291.java Wed Dec 02 23:07:58 2015 -0800 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * 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 8071291 + * @summary Compiler crashes trying to cast UnionType to IntersectionClassType + * @compile T8071291.java + */ + +class T8071291 { + + interface A { } + class Exception1 extends Exception implements A { } + class Exception2 extends Exception implements A { } + + void test(boolean cond) { + try { + if (cond) { + throw new Exception1(); + } else { + throw new Exception2(); + } + } + catch (Exception1|Exception2 x) { + if (x instanceof Exception1) { } + } + } +}