-
Bug
-
Resolution: Fixed
-
P3
-
repo-panama
With this example:
test.h
```
struct Bar {
int i;
};
struct Foo {
struct Bar bar;
};
```
$ jextract -o test.jar -t "org" test.h
Where `Foo` gets the following descriptor (note the layout hole):
"[$(Bar)(get=bar$get)(set=bar$set)(ptr=bar$ptr)](Foo)"
Main.java
```
import java.foreign.Scope;
import org.test.Foo;
public class Main {
public static void main(String[] args) {
try(Scope sc = Scope.newNativeScope()) {
Foo foo = sc.allocateStruct(Foo.class);
}
}
}
```
I'm seeing the following exception:
```
Exception in thread "main" java.lang.UnsupportedOperationException: bitsSize on Unresolved
at java.base/java.foreign.layout.Unresolved.bitsSize(Unresolved.java:49)
at java.base/java.util.stream.ReferencePipeline$5$1.accept(ReferencePipeline.java:229)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.LongPipeline.reduce(LongPipeline.java:474)
at java.base/java.util.stream.LongPipeline.sum(LongPipeline.java:432)
at java.base/java.foreign.layout.Group.bitsSize(Group.java:116)
at java.base/java.foreign.memory.LayoutType.bytesSize(LayoutType.java:50)
at java.base/jdk.internal.foreign.ScopeImpl.allocateStruct(ScopeImpl.java:99)
at main.Main.main(Main.java:11)
```
It seems to be that the layout of Bar is not being resolved before trying to allocate it.
test.h
```
struct Bar {
int i;
};
struct Foo {
struct Bar bar;
};
```
$ jextract -o test.jar -t "org" test.h
Where `Foo` gets the following descriptor (note the layout hole):
"[$(Bar)(get=bar$get)(set=bar$set)(ptr=bar$ptr)](Foo)"
Main.java
```
import java.foreign.Scope;
import org.test.Foo;
public class Main {
public static void main(String[] args) {
try(Scope sc = Scope.newNativeScope()) {
Foo foo = sc.allocateStruct(Foo.class);
}
}
}
```
I'm seeing the following exception:
```
Exception in thread "main" java.lang.UnsupportedOperationException: bitsSize on Unresolved
at java.base/java.foreign.layout.Unresolved.bitsSize(Unresolved.java:49)
at java.base/java.util.stream.ReferencePipeline$5$1.accept(ReferencePipeline.java:229)
at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.LongPipeline.reduce(LongPipeline.java:474)
at java.base/java.util.stream.LongPipeline.sum(LongPipeline.java:432)
at java.base/java.foreign.layout.Group.bitsSize(Group.java:116)
at java.base/java.foreign.memory.LayoutType.bytesSize(LayoutType.java:50)
at java.base/jdk.internal.foreign.ScopeImpl.allocateStruct(ScopeImpl.java:99)
at main.Main.main(Main.java:11)
```
It seems to be that the layout of Bar is not being resolved before trying to allocate it.