RFR: 8264696: Multi-catch clause causes compiler exception because it uses the package-private supertype
Guoxiong Li
github.com+13688759+lgxbslgx at openjdk.java.net
Thu Apr 8 04:47:38 UTC 2021
On Thu, 8 Apr 2021 02:42:26 GMT, Vicente Romero <vromero at openjdk.org> wrote:
>> Hi all,
>>
>> The method `isAccessible(Env<AttrContext> env, Type t, boolean checkInner)` should take `UnionClassType` as a special type to do some corresponding work. If not, the problem will occur. This patch fixes it and adds a test case.
>>
>> Thank you for taking the time to review.
>>
>> Best Regards.
>> -- Guoxiong
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java line 390:
>
>> 388: if (t.hasTag(ARRAY)) {
>> 389: return isAccessible(env, types.cvarUpperBound(types.elemtype(t)));
>> 390: } else if (!t.isUnion()) {
>
> I would change the code a bit, like in:
>
> } else if (t.isUnion()) {
> return StreamSupport.stream(((UnionClassType) t).getAlternativeTypes().spliterator(), false)
> .allMatch(alternative -> isAccessible(env, alternative.tsym, checkInner));
> } else {
> return isAccessible(env, t.tsym, checkInner);
> }
Very nice suggestion. Fixed.
> test/langtools/tools/javac/resolve/PackagePrivateSupertypeAtMultiCatch.java line 105:
>
>> 103: .outdir(out)
>> 104: .run()
>> 105: .writeAll();
>
> nit: you don't need the `writeAll()` method given that you are not collecting the output
Fixed.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3374
More information about the compiler-dev
mailing list