Unsafe warning on 0.28.2 and Java 24 #313

Open
opened 2025-12-30 01:23:28 +01:00 by adam · 1 comment
Owner

Originally created by @ShiftSad on GitHub (Jun 25, 2025).

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.

    /**
     * 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> T get(String key, Class<T> type) {
        return get(key).as(type);
    }

I've got it running the test bellow, it passes but throws warnig.

    @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));
    }
Originally created by @ShiftSad on GitHub (Jun 25, 2025). 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> T get(String key, Class<T> 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)); } ```
Author
Owner

@stackoverflow commented on GitHub (Jun 30, 2025):

We'll update graalvm/truffle for the 0.30 release. So, hopefully this will be fixed.

@stackoverflow commented on GitHub (Jun 30, 2025): We'll update graalvm/truffle for the 0.30 release. So, hopefully this will be fixed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#313