-
Bug
-
Resolution: Fixed
-
P4
-
None
-
None
When extracting a C struct - e.g.
```
struct Point {
int x;
int y;
}
```
Jextract emits hardwired offsets:
```
class Point {
...
private static final long x$OFFSET = 0;
...
private static final long y$OFFSET = 4;
}
```
While this is good for startup, it makes it difficult to alter the layout of a struct after the fact - e.g. by adding platform-dependent padding -- which will make all the offsets incorrect.
It would be better/more robust if the generated code looked like this:
```
class Point {
private static final long x$OFFSET = LAYOUT.byteOffset(groupLayout("x"));
...
private static final long y$OFFSET = LAYOUT.byteOffset(groupLayout("y"));
...
}
```
```
struct Point {
int x;
int y;
}
```
Jextract emits hardwired offsets:
```
class Point {
...
private static final long x$OFFSET = 0;
...
private static final long y$OFFSET = 4;
}
```
While this is good for startup, it makes it difficult to alter the layout of a struct after the fact - e.g. by adding platform-dependent padding -- which will make all the offsets incorrect.
It would be better/more robust if the generated code looked like this:
```
class Point {
private static final long x$OFFSET = LAYOUT.byteOffset(groupLayout("x"));
...
private static final long y$OFFSET = LAYOUT.byteOffset(groupLayout("y"));
...
}
```
- duplicates
-
CODETOOLS-7903804 Jextract bindings should not have hardwired offset constants
- Closed
- links to
-
Commit(master) openjdk/jextract/0614097d
-
Review(master) openjdk/jextract/262