Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple JUnit Test fails when <parallel> property is enabled in conditional agent mode #648

Open
dnestoro opened this issue Dec 4, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@dnestoro
Copy link
Collaborator

dnestoro commented Dec 4, 2024

Describe the bug
Simple JUnit test fails when I pass `true in the pom xml.

To Reproduce

Test:

    private static class Person {
        private String name;
        private String surname;
    }

    @Test
    public void reflectionTest() {
        Object person = new Person();
        Field[] fields = person.getClass().getDeclaredFields();
        List<String> actualFieldNames = Arrays.stream(fields).map(Field::getName).toList();

        Assertions.assertTrue(actualFieldNames.containsAll(Arrays.asList("name", "surname")));
    }

pom.xml:

<profile>
            <id>native</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>3.0.0</version>
                    </plugin>
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${native.maven.plugin.version}</version>
                        <extensions>true</extensions>
                        <executions>
                            <execution>
                                <id>build-native</id>
                                <goals>
                                    <goal>compile-no-fork</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                            <execution>
                                <id>test-native</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <phase>test</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <quickBuild>true</quickBuild>
                            <verbose>true</verbose>
                            <agent>
                                <enabled>true</enabled>
                                <defaultMode>Conditional</defaultMode>
                                <modes>
                                    <conditional>
                                        <userCodeFilterPath>src/test/java/org/example/filters/userCodeFilter.json</userCodeFilterPath>
                                        <parallel>true</parallel>
                                    </conditional>
                                </modes>
                                <metadataCopy>
                                    <disabledStages>
                                        <stage>main</stage>
                                    </disabledStages>
                                    <merge>true</merge>
                                    <outputDirectory>src/test/java/org/example/metadata</outputDirectory>
                                </metadataCopy>
                            </agent>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

Command:

mvn -Pnative test

The test should fail.
Remove <parallel>true</parallel> and the test should pass.

Logs

[INFO] Merging agent 1 files into /home/dnestoro/Desktop/Examples/MavenDocsTest/target/native/agent-output/test
jdk.graal.compiler.util.json.JsonParserException: line 1725 column 51 Expected , or } but found :
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.error(JsonParser.java:535)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.expectedError(JsonParser.java:555)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseObject(JsonParser.java:293)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:233)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseObject(JsonParser.java:274)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:233)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseArray(JsonParser.java:337)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:235)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseObject(JsonParser.java:274)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:233)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseArray(JsonParser.java:337)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:235)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseObject(JsonParser.java:274)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:233)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseArray(JsonParser.java:337)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:235)
        ...
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseArray(JsonParser.java:337)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:235)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseObject(JsonParser.java:274)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:233)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseArray(JsonParser.java:337)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:235)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseObject(JsonParser.java:274)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:233)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseArray(JsonParser.java:337)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:235)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseObject(JsonParser.java:274)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:233)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseObject(JsonParser.java:274)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parseLiteral(JsonParser.java:233)
        at jdk.graal.compiler/jdk.graal.compiler.util.json.JsonParser.parse(JsonParser.java:127)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.configure.ConfigurationParser.parseAndRegister(ConfigurationParser.java:90)
        at org.graalvm.nativeimage.configure/com.oracle.svm.configure.command.ConfigurationGenerateConditionalsCommand.apply(ConfigurationGenerateConditionalsCommand.java:119)
        at org.graalvm.nativeimage.configure/com.oracle.svm.configure.ConfigurationTool.main(ConfigurationTool.java:84)
        at org.graalvm.nativeimage.enterprise.configure/com.oracle.svm.enterprise.configure.ConfigurationEnterpriseTool.main(ConfigurationEnterpriseTool.java:24)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.393 s
[INFO] Finished at: 2024-12-04T10:53:40+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.10.3:merge-agent-files (test-native) on project MavenDocsTest: Execution of /home/dnestoro/.sdkman/candidates/java/23.0.1-graal/bin/native-image-configure generate-conditional --user-code-filter=src/test/java/org/example/filters/userCodeFilter.json --input-dir=/home/dnestoro/Desktop/Examples/MavenDocsTest/target/native/agent-output/test/session-16158-20241204T095339Z --output-dir=/home/dnestoro/Desktop/Examples/MavenDocsTest/target/native/agent-output/test returned non-zero result -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

System Info (please complete the following information):

  • OS: Ubuntu 22.04
  • GraalVM Version: Oracle GraalVM 23.0.1+11.1
  • Java Version: Oracle GraalVM 23.0.1+11.1
  • Plugin version 0.10.3

Additional context
The test only fails with the latest GraalVM release. Previous releases don't have this issue.

@vjovanov
Copy link
Member

@loicottet can you have a look please?

@loicottet
Copy link
Member

This looks like the bug affecting configuration with origins emission. That fix should land shortly. @dnestoro could I get a complete reproducer to confirm whether this is the case? The test class and pom file are not complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants