Mercurial > hg > icedtea8-forest > langtools
changeset 3102:076ec0ef64f0 icedtea-3.0.0pre09
Merge jdk8u72-b15
author | andrew |
---|---|
date | Fri, 05 Feb 2016 17:41:28 +0000 |
parents | 89932e50957f (current diff) 48d0c20256a3 (diff) |
children | 227b442fdfe2 |
files | .hgtags |
diffstat | 21 files changed, 618 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Fri Feb 05 03:38:14 2016 +0000 +++ b/.hgtags Fri Feb 05 17:41:28 2016 +0000 @@ -358,6 +358,7 @@ b813a76f10911ac8db2c775e52b29f36ab0005f4 jdk8u31-b31 8dc0c7e42d90c9f323582b742a7f228bad57b124 jdk8u31-b32 f75e26a5c3acc1ca9f5035dbfc4a40710d354dff jdk8u31-b33 +cbbf2cd7ed1c24856cf8fa570e70cfc793c8bd7b jdk8u31-b34 d231957fe3103e790465fcf058fb8cb33bbc4c4e jdk8u40-b00 bf89a471779d13a9407f7d1c86f7716258bc4aa6 jdk8u40-b01 0b6cc4ea670f5d17b56c088f202869bdbb80a5ce jdk8u40-b02 @@ -409,6 +410,11 @@ ebe1e9d17713e45d157b48b9a31c5c2d077c7970 jdk8u45-b15 10fae8059bb210df1624b827a3895ccc455e3c64 jdk8u45-b31 e0b8d79bef0c01d77453579b1d36e926892c774b jdk8u45-b32 +215ac00f188ef920a2f0f25257c96550f410bc5e jdk8u45-b33 +67733b5f2dee681e9590f1224df97132a37c2314 jdk8u45-b34 +a7b242cd24d1dae36d79dec6746896de4414823b jdk8u45-b35 +06aa26ac40d82df216f28ead7b2ae6d59b66f461 jdk8u45-b36 +e233228c112c1e796747d303324284c86b3ef8e2 jdk8u45-b37 ac1c3ae884633c2ec3881816977023fc44919c66 jdk8u51-b00 565167bf31eab083c306dfe11c947e59f4f4ee72 jdk8u51-b01 2078bad2444c509a63a539f3bbe1db0f36513c9e jdk8u51-b02 @@ -426,6 +432,9 @@ f3a44c7deac2b23a53f0fd35b22a5d9181291616 jdk8u51-b14 f77e8d012e8d6ee3432515ad68dd4f630dd08d56 jdk8u51-b15 e27a094cb423a3bf32906969e9e454e061ce94d4 jdk8u51-b16 +57ea4856a08f0bc87f2fe56d57b3cf1497c0cb51 jdk8u51-b31 +153378991303acf7906684380a025347a95bc95e jdk8u51-b32 +e7810a2613c9b9b407125cbd17add7bfeebfdb03 jdk8u51-b33 0c514d1fd006fc79d35b670de10c370c8d559db7 jdk8u60-b00 0ba07c272e33c93377a5d7ed98b9de873cc91980 jdk8u60-b01 387cf62ce7895dd5e067aaa51faa93d5c078583e jdk8u60-b02 @@ -453,3 +462,80 @@ 69b782e543d54118f9354b6071830de5feb96b83 icedtea-3.0.0pre06 3c76eafe1b7010bf5536add7097c318d349efb16 icedtea-3.0.0pre07 0d3479e0bac61b3fab0f8e884fc6bda8f8f351a5 icedtea-3.0.0pre08 +2af11e10da7dc24610551bbeed02c4ca3f4ae654 jdk8u60-b24 +8d152d1e45944616309886e730ffcbfb5c078d22 jdk8u60-b25 +3876ab6f471b85a02bb2cdaca00652f169f9e27a jdk8u60-b26 +e8e293d0db49b717f8cfc2c8fa5926bcec0f2941 jdk8u60-b27 +11907015714ab0bb44e27f0bb32365dc1669ac51 jdk8u60-b31 +f928484c17d6d27cc3b866ea6fe878058b518372 jdk8u60-b32 +779397f90251ea813cb44621dc27f780e5c20449 jdk8u52-b06 +e0ce6be9142ed1e2f0ce3ee13090ec01c6c44721 jdk8u52-b07 +779397f90251ea813cb44621dc27f780e5c20449 jdk8u65-b00 +c4dcc4e75218f222b80b21d2044baeb98f1f7143 jdk8u65-b01 +57a11f869f0a469798d571197403947bdd8f0525 jdk8u65-b02 +0e03089b5bb37450c7bcab8fc9cb0912e24fe681 jdk8u65-b03 +b90367f392f5d7af47c26bae5493adc73a865c70 jdk8u65-b04 +b2e8d2c5636f5f98a10b9e800ea10e0fe4c265c3 jdk8u65-b05 +ae5e31450299f6c265df24ed155acd650fb3bffd jdk8u65-b06 +c80e74eb5aaa6abe74c7cf110a41290317bc4efb jdk8u65-b07 +5e00d983801dd8764c7cdccdede6d026f6033b66 jdk8u65-b08 +9a8c4add20b277917466d48398071e0965f3deee jdk8u65-b09 +f3f51e2bce4b243ab7abb9e83dfb20cc706939e8 jdk8u65-b10 +f3f51e2bce4b243ab7abb9e83dfb20cc706939e8 jdk8u65-b10 +0000000000000000000000000000000000000000 jdk8u65-b10 +0000000000000000000000000000000000000000 jdk8u65-b10 +f72616a2c088fb2918d730b4eeea6c86f84d1f04 jdk8u65-b10 +2628c6cd89512e40a97baf79465c68147ed750d4 jdk8u65-b11 +54e958a3719e6af61f16e1fa3bcca9422738e4dd jdk8u65-b12 +153d0309e6986149e763597edd20250485160734 jdk8u65-b13 +ec4fa681ae411edc666a60ca5470a56c5cf0fa81 jdk8u65-b14 +02e92f7edc325dc1d17141477ee851a1cc7e71d8 jdk8u65-b15 +20703c32d5ae5d53ecb40bcef79ae933558411aa jdk8u65-b16 +d038f63e516730c240b5ee0559fc7b09c22393c4 jdk8u65-b17 +d1febf79ce5ea41fb4b818ffd3589cf923e6de5f jdk8u66-b00 +4c13b9cd06222be73b9c44607ae929b4818aed17 jdk8u66-b01 +ec4e102b4bd02b08336e172047e70971a3ed7489 jdk8u66-b02 +a765210439a2544a4570deda6d9400363cd18b48 jdk8u66-b07 +8d4dc964a44ba0d55dccbcf7ac840f70bc523e20 jdk8u66-b08 +93a0c0eb33d47c5a6f096dcf531ee062480e1cd7 jdk8u66-b09 +09600814af4e1dbf9de8e5bcec0316ec0bb92c20 jdk8u66-b10 +b71e6a08899271f3f6c02af2abc3c72b2eaad797 jdk8u66-b11 +7ea15c71137ffc344fa4ef3eefb69da94713e841 jdk8u66-b12 +55656a3a71be6674c215b670354ee6e2a7f1c839 jdk8u66-b13 +70489ab07527a3ef65e2a30f23b164220466775a jdk8u66-b14 +8063e4ac4caabe1756f8393859ab56da3bb29122 jdk8u66-b15 +01e7f91d993b341986f574d0eb3fbfe3d7cae68e jdk8u66-b16 +ad3f528335b4c609eee7227d150c9a0a39b1dd73 jdk8u66-b17 +ee701de614ad0c5f4bf3a553942909a54084c458 jdk8u66-b18 +f55af75598d85f45f779f3e632152a067fb7efbc jdk8u66-b31 +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 +12889f37d0573ddbcf0738843f013ac89b3f0cb3 jdk8u71-b12 +ceba7d950f1d4055628dbddbcb5c39b9888b7333 jdk8u71-b13 +87d69c4a77b4ca9bc3a8304fc6591ca10c80bfe5 jdk8u71-b14 +f693ae53d58c81d6f319b402dfd3ed8bf14ed7bc jdk8u71-b15 +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 +5218bea65fe64b31cf201f3f6dd0310b74acec1e jdk8u72-b12 +5b67278c6616dca433488697eb6f2f81fcbbf22d jdk8u72-b13 +0ee6d8ae247d449950c18623513ccae4349e70d6 jdk8u72-b14
--- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard_ja.properties Fri Feb 05 17:41:28 2016 +0000 @@ -190,4 +190,4 @@ # L10N: do not localize these words: all none accessibility html missing reference syntax -doclet.X.usage=\u6A19\u6E96\u306Edoclet\u306B\u3088\u308A\u63D0\u4F9B\u3055\u308C\u308B\u3082\u306E:\n -Xdocrootparent <url> doc\u30B3\u30E1\u30F3\u30C8\u5185\u306E/..\u304C\u5F8C\u306B\u7D9A\u304F@docRoot\u306E\u3059\u3079\u3066\u3092\n <url>\u3067\u7F6E\u63DB\u3057\u307E\u3059\n -Xdoclint javadoc\u30B3\u30E1\u30F3\u30C8\u5185\u306E\u554F\u984C\u306B\u5BFE\u3059\u308B\u63A8\u5968\u3055\u308C\u308B\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u306B\u3057\u307E\u3059\n -Xdoclint:(all|none|[-]<group>) \n javadoc\u30B3\u30E1\u30F3\u30C8\u5185\u306E\u554F\u984C\u306B\u5BFE\u3059\u308B\u7279\u5B9A\u306E\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u307E\u305F\u306F\u7121\u52B9\u306B\u3057\u307E\u3059\u3002\n \u3053\u3053\u3067\u3001<group>\u306Fhtml\u3001missing\u3001reference\u307E\u305F\u306Fsyntax\u306E\u3044\u305A\u308C\u304B\u3067\u3059\u3002\n +doclet.X.usage=\u6A19\u6E96\u306Edoclet\u306B\u3088\u308A\u63D0\u4F9B\u3055\u308C\u308B\u3082\u306E:\n -Xdocrootparent <url> doc\u30B3\u30E1\u30F3\u30C8\u5185\u306E/..\u304C\u5F8C\u306B\u7D9A\u304F@docRoot\u306E\u3059\u3079\u3066\u3092\n <url>\u3067\u7F6E\u63DB\u3057\u307E\u3059\n -Xdoclint javadoc\u30B3\u30E1\u30F3\u30C8\u5185\u306E\u554F\u984C\u306B\u5BFE\u3059\u308B\u63A8\u5968\u3055\u308C\u308B\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u306B\u3057\u307E\u3059\n -Xdoclint:(all|none|[-]<group>) \n javadoc\u30B3\u30E1\u30F3\u30C8\u5185\u306E\u554F\u984C\u306B\u5BFE\u3059\u308B\u7279\u5B9A\u306E\u30C1\u30A7\u30C3\u30AF\u3092\u6709\u52B9\u307E\u305F\u306F\u7121\u52B9\u306B\u3057\u307E\u3059\u3002\n \u3053\u3053\u3067\u3001<group>\u306Faccessibility\u3001html\u3001missing\u3001reference\u307E\u305F\u306Fsyntax\u306E\u3044\u305A\u308C\u304B\u3067\u3059\u3002\n
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_ja.properties Fri Feb 05 17:41:28 2016 +0000 @@ -148,6 +148,13 @@ doclet.Constructors=\u30B3\u30F3\u30B9\u30C8\u30E9\u30AF\u30BF doclet.methods=\u30E1\u30BD\u30C3\u30C9 doclet.Methods=\u30E1\u30BD\u30C3\u30C9 +doclet.All_Methods=\u3059\u3079\u3066\u306E\u30E1\u30BD\u30C3\u30C9 +doclet.Static_Methods=static\u30E1\u30BD\u30C3\u30C9 +doclet.Instance_Methods=\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u30FB\u30E1\u30BD\u30C3\u30C9 +doclet.Abstract_Methods=abstract\u30E1\u30BD\u30C3\u30C9 +doclet.Concrete_Methods=concrete\u30E1\u30BD\u30C3\u30C9 +doclet.Default_Methods=\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30E1\u30BD\u30C3\u30C9 +doclet.Deprecated_Methods=\u63A8\u5968\u3055\u308C\u3066\u3044\u306A\u3044\u30E1\u30BD\u30C3\u30C9 doclet.annotation_type_optional_members=\u4EFB\u610F\u8981\u7D20 doclet.Annotation_Type_Optional_Members=\u4EFB\u610F\u8981\u7D20 doclet.annotation_type_required_members=\u5FC5\u9808\u8981\u7D20
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets_zh_CN.properties Fri Feb 05 17:41:28 2016 +0000 @@ -148,6 +148,13 @@ doclet.Constructors=\u6784\u9020\u5668 doclet.methods=\u65B9\u6CD5 doclet.Methods=\u65B9\u6CD5 +doclet.All_Methods=\u6240\u6709\u65B9\u6CD5 +doclet.Static_Methods=\u9759\u6001\u65B9\u6CD5 +doclet.Instance_Methods=\u5B9E\u4F8B\u65B9\u6CD5 +doclet.Abstract_Methods=\u62BD\u8C61\u65B9\u6CD5 +doclet.Concrete_Methods=\u5177\u4F53\u65B9\u6CD5 +doclet.Default_Methods=\u9ED8\u8BA4\u65B9\u6CD5 +doclet.Deprecated_Methods=\u5DF2\u8FC7\u65F6\u7684\u65B9\u6CD5 doclet.annotation_type_optional_members=\u53EF\u9009\u5143\u7D20 doclet.Annotation_Type_Optional_Members=\u53EF\u9009\u5143\u7D20 doclet.annotation_type_required_members=\u5FC5\u9700\u7684\u5143\u7D20
--- a/src/share/classes/com/sun/tools/javac/code/Type.java Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Fri Feb 05 17:41:28 2016 +0000 @@ -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 Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Fri Feb 05 17:41:28 2016 +0000 @@ -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 Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Feb 05 17:41:28 2016 +0000 @@ -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 Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Feb 05 17:41:28 2016 +0000 @@ -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 Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Feb 05 17:41:28 2016 +0000 @@ -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/LambdaToMethod.java Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Fri Feb 05 17:41:28 2016 +0000 @@ -1179,12 +1179,14 @@ @Override public void visitClassDef(JCClassDecl tree) { List<Frame> prevStack = frameStack; + int prevLambdaCount = lambdaCount; SyntheticMethodNameCounter prevSyntheticMethodNameCounts = syntheticMethodNameCounts; Map<ClassSymbol, Symbol> prevClinits = clinits; DiagnosticSource prevSource = log.currentSource(); try { log.useSource(tree.sym.sourcefile); + lambdaCount = 0; syntheticMethodNameCounts = new SyntheticMethodNameCounter(); prevClinits = new HashMap<ClassSymbol, Symbol>(); if (tree.sym.owner.kind == MTH) { @@ -1211,6 +1213,7 @@ finally { log.useSource(prevSource.getFile()); frameStack = prevStack; + lambdaCount = prevLambdaCount; syntheticMethodNameCounts = prevSyntheticMethodNameCounts; clinits = prevClinits; }
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Fri Feb 05 17:41:28 2016 +0000 @@ -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 Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties Fri Feb 05 17:41:28 2016 +0000 @@ -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 Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Fri Feb 05 17:41:28 2016 +0000 @@ -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 Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties Fri Feb 05 17:41:28 2016 +0000 @@ -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
--- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Feb 05 17:41:28 2016 +0000 @@ -124,19 +124,14 @@ * Returns the flags of a ClassSymbol in terms of javac's flags */ static long getFlags(ClassSymbol clazz) { - while (true) { - try { - return clazz.flags(); - } catch (CompletionFailure ex) { - /* Quietly ignore completion failures. - * Note that a CompletionFailure can only - * occur as a result of calling complete(), - * which will always remove the current - * completer, leaving it to be null or - * follow-up completer. Thus the loop - * is guaranteed to eventually terminate. - */ - } + try { + return clazz.flags(); + } catch (CompletionFailure ex) { + /* Quietly ignore completion failures and try again - the type + * for which the CompletionFailure was thrown shouldn't be completed + * again by the completer that threw the CompletionFailure. + */ + return getFlags(clazz); } }
--- a/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java Fri Feb 05 17:41:28 2016 +0000 @@ -128,7 +128,7 @@ t.hasTag(CLASS); t = env.types.supertype(t)) { ClassSymbol c = (ClassSymbol)t.tsym; - for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) { + for (Scope.Entry e = membersOf(c).lookup(sym.name); e.scope != null; e = e.next()) { if (sym.overrides(e.sym, origin, env.types, true)) { return TypeMaker.getType(env, t); } @@ -160,7 +160,7 @@ t.hasTag(CLASS); t = env.types.supertype(t)) { ClassSymbol c = (ClassSymbol)t.tsym; - for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) { + for (Scope.Entry e = membersOf(c).lookup(sym.name); e.scope != null; e = e.next()) { if (sym.overrides(e.sym, origin, env.types, true)) { return env.getMethodDoc((MethodSymbol)e.sym); } @@ -169,6 +169,19 @@ return null; } + /**Retrieve members of c, ignoring any CompletionFailures that occur. */ + private Scope membersOf(ClassSymbol c) { + try { + return c.members(); + } catch (CompletionFailure cf) { + /* Quietly ignore completion failures and try again - the type + * for which the CompletionFailure was thrown shouldn't be completed + * again by the completer that threw the CompletionFailure. + */ + return membersOf(c); + } + } + /** * Tests whether this method overrides another. * The overridden method may be one declared in a superclass or
--- a/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Fri Feb 05 03:38:14 2016 +0000 +++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java Fri Feb 05 17:41:28 2016 +0000 @@ -28,6 +28,7 @@ import com.sun.javadoc.*; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.ClassSymbol; +import com.sun.tools.javac.code.Symbol.CompletionFailure; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Type.ArrayType; import com.sun.tools.javac.code.Type.ClassType; @@ -56,8 +57,21 @@ return getType(env, t, errorToClassDoc, true); } + public static com.sun.javadoc.Type getType(DocEnv env, Type t, + boolean errToClassDoc, boolean considerAnnotations) { + try { + return getTypeImpl(env, t, errToClassDoc, considerAnnotations); + } catch (CompletionFailure cf) { + /* Quietly ignore completion failures and try again - the type + * for which the CompletionFailure was thrown shouldn't be completed + * again by the completer that threw the CompletionFailure. + */ + return getType(env, t, errToClassDoc, considerAnnotations); + } + } + @SuppressWarnings("fallthrough") - public static com.sun.javadoc.Type getType(DocEnv env, Type t, + private static com.sun.javadoc.Type getTypeImpl(DocEnv env, Type t, boolean errToClassDoc, boolean considerAnnotations) { if (env.legacyDoclet) { t = env.types.erasure(t);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/lambdaNaming/TestNonSerializableLambdaNameStability.java Fri Feb 05 17:41:28 2016 +0000 @@ -0,0 +1,157 @@ +/* + * 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 8067422 + * @summary Check that the lambda names are not unnecessarily unstable + * @run main TestNonSerializableLambdaNameStability + */ + +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Method; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.tools.FileObject; +import javax.tools.ForwardingJavaFileManager; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileManager; +import javax.tools.JavaFileObject; +import javax.tools.JavaFileObject.Kind; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +public class TestNonSerializableLambdaNameStability { + + public static void main(String... args) throws Exception { + new TestNonSerializableLambdaNameStability().run(); + } + + String lambdaSource = "public class L%d {\n" + + " public static class A {\n" + + " private Runnable r = () -> { };\n" + + " }\n" + + " public static class B {\n" + + " private Runnable r = () -> { };\n" + + " }\n" + + " private Runnable r = () -> { };\n" + + "}\n"; + + String expectedLambdaMethodName = "lambda$new$0"; + + void run() throws Exception { + List<JavaFileObject> sources = new ArrayList<>(); + + for (int i = 0; i < 3; i++) { + sources.add(new SourceJavaFileObject("L" + i, String.format(lambdaSource, i))); + } + + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + + try (MemoryFileManager fm = new MemoryFileManager(compiler.getStandardFileManager(null, null, null))) { + if (!compiler.getTask(null, fm, null, null, null, sources).call()) { + throw new AssertionError("Compilation failed!"); + } + + for (String file : fm.name2Content.keySet()) { + byte[] fileBytes = fm.name2Content.get(file); + try (InputStream in = new ByteArrayInputStream(fileBytes)) { + boolean foundLambdaMethod = false; + ClassFile cf = ClassFile.read(in); + StringBuilder seenMethods = new StringBuilder(); + String sep = ""; + for (Method m : cf.methods) { + String methodName = m.getName(cf.constant_pool); + if (expectedLambdaMethodName.equals(methodName)) { + foundLambdaMethod = true; + break; + } + seenMethods.append(sep); + seenMethods.append(methodName); + sep = ", "; + } + + if (!foundLambdaMethod) { + throw new AbstractMethodError("Did not find the lambda method, " + + "found methods: " + seenMethods.toString()); + } + } + } + } + } + + class MemoryFileManager extends ForwardingJavaFileManager<JavaFileManager> { + + final Map<String, byte[]> name2Content = new HashMap<>(); + + public MemoryFileManager(JavaFileManager fileManager) { + super(fileManager); + } + + @Override + public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException { + try { + return new SimpleJavaFileObject(new URI("mem://" + className.replace('.', '/') + kind.extension), kind) { + @Override public OutputStream openOutputStream() throws IOException { + return new ByteArrayOutputStream() { + @Override public void close() throws IOException { + super.close(); + name2Content.put(className, toByteArray()); + } + }; + } + }; + } catch (URISyntaxException ex) { + throw new AssertionError(ex); + } + } + + } + + class SourceJavaFileObject extends SimpleJavaFileObject { + + private final String code; + + public SourceJavaFileObject(String name, String code) throws URISyntaxException { + super(new URI("mem:///" + name + ".java"), Kind.SOURCE); + this.code = code; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return code; + } + + } +}
--- a/test/tools/javac/links/LinksTest.java Fri Feb 05 03:38:14 2016 +0000 +++ b/test/tools/javac/links/LinksTest.java Fri Feb 05 17:41:28 2016 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -30,6 +30,7 @@ * @run main LinksTest */ +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -48,19 +49,26 @@ throws Exception { // mkdir tmp // cp ${TESTSRC}/b/B.java tmp - ToolBox.writeFile(Paths.get("tmp", "B.java"), BSrc); + ToolBox.writeFile(Paths.get("tmp/B.java"), BSrc); + // Try to set up a symbolic link for the test. +// ln -s `pwd`/tmp "${TESTCLASSES}/a" try { -// ln -s `pwd`/tmp "${TESTCLASSES}/a" Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp")); - ////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1 - ToolBox.JavaToolArgs javacArgs = - new ToolBox.JavaToolArgs() - .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc); - ToolBox.javac(javacArgs); - } catch (UnsupportedOperationException e) { - System.err.println("Symbolic links not supported on this system. The test can't finish"); + System.err.println("Created symbolic link"); + } catch (UnsupportedOperationException | IOException e) { + System.err.println("Problem creating symbolic link: " + e); + System.err.println("Test cannot continue; test passed by default"); + return; } + + // If symbolic link was successfully created, + // try a compilation that will use it. + ////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1 + ToolBox.JavaToolArgs javacArgs = + new ToolBox.JavaToolArgs() + .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc); + ToolBox.javac(javacArgs); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/multicatch/8071291/T8071291.java Fri Feb 05 17:41:28 2016 +0000 @@ -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) { } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javadoc/CompletionError.java Fri Feb 05 17:41:28 2016 +0000 @@ -0,0 +1,174 @@ +/* + * 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 8135307 + * @summary Check that CompletionFailures for missing classes are not incorrectly passed to + * the javadoc API clients. + * @modules jdk.javadoc + * @run main CompletionError + */ + +import java.io.File; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; + +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +import com.sun.javadoc.*; +import com.sun.tools.javadoc.Main; + +public class CompletionError extends Doclet +{ + private static final String template = + "public class CompletionErrorAuxiliary #extends CompletionErrorMissing# #implements CompletionErrorIntfMissing# {" + + " #public CompletionErrorMissing tf;#" + + " #public CompletionErrorMissing tm() { return null; }#" + + " #public void tm(CompletionErrorMissing m) {}#" + + " #public void tm() throws CompletionErrorExcMissing {}#" + + " #public <T extends CompletionErrorMissing> void tm() {}#" + + " public String toString() { return null; }" + + "}"; + + public static void main(String[] args) throws Exception { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + String[] templateParts = template.split("#"); + int sources = templateParts.length / 2; + for (int source = 0; source < sources; source++) { + StringBuilder testSource = new StringBuilder(); + for (int i = 0; i < templateParts.length; i += 2) { + testSource.append(templateParts[i]); + if (i == 2 * source) { + testSource.append(templateParts[i + 1]); + } + } + test = 0; + testsDone = false; + while (!testsDone) { + List<JavaSource> fileObjects = + Arrays.asList(new JavaSource("CompletionErrorAuxiliary", testSource.toString()), + new JavaSource("CompletionErrorMissing", "public class CompletionErrorMissing {}"), + new JavaSource("CompletionErrorIntfMissing", "public interface CompletionErrorIntfMissing {}"), + new JavaSource("CompletionErrorExcMissing", "public class CompletionErrorExcMissing extends Exception {}")); + Boolean result = compiler.getTask(null, null, null, Arrays.asList("-d", "."), null, fileObjects).call(); + if (!result) + throw new Error(); + for (String delete : new String[] {"CompletionErrorMissing.class", "CompletionErrorIntfMissing.class", "CompletionErrorExcMissing.class"}) { + Files.delete(Paths.get(delete)); + } + // run javadoc: + if (Main.execute("javadoc", "CompletionError", CompletionError.class.getClassLoader(), + "-classpath", ".", + System.getProperty("test.src", ".") + File.separatorChar + "CompletionError.java") != 0) + throw new Error(); + } + } + } + + private static int test; + private static boolean testsDone; + + public static boolean start(com.sun.javadoc.RootDoc root) { + ClassDoc aux = root.classNamed("CompletionErrorAuxiliary"); + if (aux == null) + throw new AssertionError("Cannot find CompletionErrorAuxiliary"); + + FieldDoc tf = findField(aux, "tf"); + MethodDoc tm = findMethod(aux, "tm"); + MethodDoc cm = findMethod(aux, "toString"); + switch (test) { + case 0: aux.superclass(); break; + case 1: aux.superclassType(); break; + case 2: aux.interfaces(); break; + case 3: aux.interfaceTypes(); break; + case 4: if (tf != null) tf.type(); break; + case 5: if (tm != null) tm.overriddenClass(); break; + case 6: if (tm != null) tm.overriddenMethod(); break; + case 7: if (tm != null) tm.overriddenType(); break; + case 8: + if (tm != null) { + for (Parameter p : tm.parameters()) { + p.type(); + } + } + break; + case 9: if (tm != null) tm.receiverType(); break; + case 10: if (tm != null) tm.returnType(); break; + case 11: if (tm != null) tm.thrownExceptionTypes(); break; + case 12: if (tm != null) tm.thrownExceptions(); break; + case 13: + if (tm != null) { + for (TypeVariable tv : tm.typeParameters()) { + tv.bounds(); + } + } + break; + case 14: if (cm != null) cm.overriddenClass(); break; + case 15: if (cm != null) cm.overriddenMethod(); break; + case 16: if (cm != null) cm.overriddenType(); testsDone = true; break; + default: + throw new IllegalStateException("Unrecognized test!"); + } + test++; + return true; + } + + private static MethodDoc findMethod(ClassDoc cd, String name) { + for (MethodDoc m : cd.methods()) { + if (name.equals(m.name())) + return m; + } + + return null; + } + + private static FieldDoc findField(ClassDoc cd, String name) { + for (FieldDoc m : cd.fields()) { + if (name.equals(m.name())) + return m; + } + + return null; + } + + static class JavaSource extends SimpleJavaFileObject { + final String source; + + public JavaSource(String name, String source) { + super(URI.create("myfo:/" + name + ".java"), JavaFileObject.Kind.SOURCE); + this.source = source; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } +}