[foreign] RFR: Fix UndefinedLayoutException exception message

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Jan 29 21:03:33 UTC 2019


This revision looks good to me - I like the simple test.

Maurizio

On 29/01/2019 19:18, Jorn Vernee wrote:
> Maurizio Cimadamore schreef op 2019-01-29 18:56:
>>> Then try with
>>>
>>> scope.allocate(LayoutType.ofStruct(BadStruct.class)).get().foo()
>>>
>>>
>> Ok, the above also doesn't work - but this should?
>>
>> scope.allocate(LayoutType.ofStruct(BadStruct.class).pointer()).get().get().foo() 
>>
>
> This also works, but tbh it doesn't seem much different than 
> `scope.allocate(VOID).cast(LayoutType.ofStruct(BadStruct.class)).get()`, 
> since we're dereferencing an invalid pointer in both cases.
>
>>
>> This time we should be able to bypass Scope.allocateInternal...
>>
>> The main issue about having a cross header ref is that the test is
>> gonna be sensitive to whatever we do in that area - e.g. that failure
>> is, in a way, temporary; it would be preferrable to have a test that
>> really checked something Bad (TM).
>
> FWIW, someone could write their own descriptor for an @NativeFunction 
> and accidentally put in a reference to something that just doesn't 
> exist at all, e.g.:
>
> ```
> @NativeHeader
> interface Lib {
>     @NativeFunction("()${Garbage}")
>     int func();
> }
> ```
>
> That seems like a relatively simple but still realistic test case.
>
> Updated webrev: 
> http://cr.openjdk.java.net/~jvernee/panama/webrevs/fixmessage/webrev.02/
>
> Jorn
>
>> Maurizio


More information about the panama-dev mailing list