[foreign] RFR: Fix UndefinedLayoutException exception message

Jorn Vernee jbvernee at xs4all.nl
Tue Jan 29 19:18:20 UTC 2019


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