Unsafe warning on 0.28.2 and Java 24
- Dominant language
- Java
- Stars
- 11.5k
- Forks
- 402
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 20
Description
I'm on pkl-config-java-all version 0.28.2, Pkl 0.28.2 (Windows 10.0, native) and OpenJDK 24.0.1
Warning:
```
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by com.oracle.truffle.api.nodes.NodeClassImpl$NodeFieldData (file:/C:/Users/---/.gradle/caches/modules-2/files-2.1/org.pkl-lang/pkl-config-java-all/0.28.2/1cead8c0419840532c33b53da3295b56853140f1/pkl-config-java-all-0.28.2.jar)
WARNING: Please consider reporting this to the maintainers of class com.oracle.truffle.api.nodes.NodeClassImpl$NodeFieldData
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
```
My configuration loader class has these two methods for acessing data, and they seem related to the warning being thrown.
```java
/**
* Returns the child node with the given unqualified name.
* Allows for nested keys using dot notation (e.g., "parent.child").
*
* @throws NoSuchChildException if a child with the given name does not exist
*/
public Config get(String key) {
String[] parts = key.split("\\.");
Config current = config;
for (String part : parts) {
current = current.get(part);
}
return current;
}
/**
* Returns the child node with the given unqualified name and converts it to the specified type.
*
* @throws NoSuchChildException if a child with the given name does not exist
* @throws ConversionException if the value cannot be converted to the given type
*/
public T get(String key, Class type) {
return get(key).as(type);
}
```
I've got it running the test bellow, it passes but throws warnig.
```java
@BeforeEach
void setUp() throws IOException {
Files.createDirectories(tempDir);
tempConfigFile = tempDir.resolve("my-app-test.pkl");
Files.writeString(tempConfigFile,
"app { \n" +
" name = \"TestApp\" \n" +
" version = 1.0 \n" +
" enabled = true \n" +
"}\n" +
"server {\n" +
" port = 8080\n" +
" timeout = 5000\n" +
"}"
);
tempDefaultConfigFile = tempDir.resolve(TEST_RESOURCE_CONFIG);
Files.deleteIfExists(tempDefaultConfigFile);
}
@Test
@DisplayName("Should load an existing configuration file successfully")
void testLoadExistingFile_success() throws IOException {
ConfigurationLoader loader = new ConfigurationLoader(tempConfigFile.toString());
assertNotNull(loader);
assertEquals("TestApp", loader.get("app.name", String.class));
assertEquals(1.0, loader.get("app.version", Double.class));
assertTrue(loader.get("app.enabled", Boolean.class));
}
```
Contributor guide
Research direction
Reproduce the warning with pkl-config-java-all 0.28.2, Pkl 0.28.2, and OpenJDK 24 using the supplied ConfigurationLoader test. Start by tracing the warning to com.oracle.truffle.api.nodes.NodeClassImpl$NodeFieldData and determine whether the change belongs in this project or an upstream dependency. Done means the Java 24 test completes without the Unsafe warning, or the issue is documented as externally owned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100