RFR 8203436: javac should fail early when emitting illegal signature attributes

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri May 18 20:46:09 UTC 2018


Thanks,

I discovered another interesting test:

interface A { }
interface B { }

class Outer<X> {
    class Inner { }

    <Z extends A & B> Outer<Z> m() { return null; }

    void test(Outer<?> outer) {
       m().new Inner() { };
    }
}


This time it attempts to create a signature attribute with an 
intersection. This used to crash javac in 5-10, but with this patch a 
regular error message is emitted:

error: error while generating class <anonymous Outer$1>
   (illegal signature attribute for type INT#1)
   where INT#1 is an intersection type:
     INT#1 extends Object,A,B
1 error


I'll add this test to the patch.

Maurizio


On 18/05/18 19:28, Vicente Romero wrote:
> looks good!
> Vicente
>
> On 05/18/2018 02:12 PM, Maurizio Cimadamore wrote:
>> Hi,
>> this patch makes javac a bit stricter when it comes to generating 
>> bytecode that has illegal signature attributes (which can happen in 
>> case of non-denotable types). Instead of allowing compilation and 
>> then fail at verify time, this patch issues an error message.
>>
>> I've refactored another generation-related diagnostic to share the 
>> same 'header' - an example of the diagnostics involved is included in 
>> the webrev.
>>
>> http://cr.openjdk.java.net/~mcimadamore/8203436/
>>
>> Cheers
>> Maurizio
>>
>



More information about the compiler-dev mailing list