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

java.lang.UnsatisfiedLinkError: no awt in java.library.path #714

Closed
dvfedrush opened this issue Aug 11, 2022 · 2 comments · Fixed by #1124
Closed

java.lang.UnsatisfiedLinkError: no awt in java.library.path #714

dvfedrush opened this issue Aug 11, 2022 · 2 comments · Fixed by #1124
Assignees
Labels
ctg-bug Issue is a bug

Comments

@dvfedrush
Copy link

Description

Couldn't generate some tests. Errors -> java.lang.UnsatisfiedLinkError: no awt in java.library.path

To Reproduce

Try to generate tests for a following class:

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class Solution672916 {
    /**
     * get image height and width using java
     */
    public int[] func_1(String filename) throws IOException {
        BufferedImage bimg = ImageIO.read(new File(filename));
        return new int[] {bimg.getHeight(), bimg.getWidth()};
    }
}

Expected behavior

Generated any tests (mocking BufferedImage)

Actual behavior

import org.junit.Test;

import java.io.IOException;

public class Solution672916Test {
    ///region Test suites for executable com.huawei.sof.benchmark.Solution672916.func_1

    ///region

    @Test(timeout = 50L)
    //@org.junit.jupiter.api.DisplayName("func_1: filename = blank string")
    public void testFunc_1WithBlankString() throws IOException {
        Solution672916 solution672916 = new Solution672916();
        
        /* This execution may take longer than the 50 ms timeout
         and therefore fail due to exceeding the timeout. */
        solution672916.func_1("   ");
    }

    @Test(expected = NoClassDefFoundError.class)
    //@org.junit.jupiter.api.DisplayName("func_1: filename has special characters -> throw NoClassDefFoundError")
    public void testFunc_1ThrowsNCDFEWithBlankString() throws IOException {
        Solution672916 solution672916 = new Solution672916();

        solution672916.func_1("\n\t\r");
    }
    ///endregion

    ///region ERROR SUITE for method func_1(java.lang.String)

    /**
     * <pre>
     * Test
     * throws NullPointerException in: BufferedImage bimg = ImageIO.read(new File(filename));
     * </pre>
     */
    @Test(expected = NullPointerException.class)
    //@org.junit.jupiter.api.DisplayName("func_1: bimg = ImageIO.read(new File(filename)) : True -> ThrowNullPointerException")
    public void testFunc_1_ThrowNullPointerException() throws IOException {
        Solution672916 solution672916 = new Solution672916();

        solution672916.func_1(null);
    }
    ///endregion

    ///region Errors report for func_1

    public void testFunc_1_errors() {
        // Couldn't generate some tests. List of errors:
        // 
        // 2 occurrences of:
        /* Error in the child process |> java.lang.IllegalStateException: No field $__is_mock_null
        in class javax.imageio.ImageIO
        		at org.utbot.framework.concrete.MethodMockController.<init>(MethodMockController.kt:37)
        		at org.utbot.framework.concrete.MockValueConstructor.mockMethods(MockValueConstructor.kt:247)
        		at org.utbot.framework.concrete.MockValueConstructor.mockStaticMethods(MockValueConstructor.kt:265)
        		at org.utbot.framework.concrete.UtExecutionInstrumentation$invoke$$inlined$withReflection$lambda$1.invoke(UtExecutionInstrumentation.kt:155)
        		at org.utbot.framework.concrete.UtExecutionInstrumentation$invoke$$inlined$withReflection$lambda$1.invoke(UtExecutionInstrumentation.kt:107)
        		at org.utbot.framework.concrete.UtExecutionInstrumentation.withStaticFields(UtExecutionInstrumentation.kt:269)
        		at org.utbot.framework.concrete.UtExecutionInstrumentation.invoke(UtExecutionInstrumentation.kt:153)
        		at org.utbot.framework.concrete.UtExecutionInstrumentation.invoke(UtExecutionInstrumentation.kt:107)
        		at org.utbot.instrumentation.process.ChildProcessKt.loop(ChildProcess.kt:133)
        		at org.utbot.instrumentation.process.ChildProcessKt.main(ChildProcess.kt:77)
        		at org.utbot.instrumentation.process.ChildProcessKt.main(ChildProcess.kt)
        	 */

        // 1 occurrences of:
        /* Error in the child process |> java.lang.UnsatisfiedLinkError: no awt in
        java.library.path
        		at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2660)
        		at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:829)
        		at java.base/java.lang.System.loadLibrary(System.java:1867)
        		at java.desktop/java.awt.image.ColorModel$1.run(ColorModel.java:209)
        		at java.desktop/java.awt.image.ColorModel$1.run(ColorModel.java:207)
        		at java.base/java.security.AccessController.doPrivileged(Native Method)
        		at java.desktop/java.awt.image.ColorModel.loadLibraries(ColorModel.java:206)
        		at java.desktop/java.awt.image.ColorModel.<clinit>(ColorModel.java:219)
        		at java.desktop/java.awt.image.BufferedImage.<clinit>(BufferedImage.java:286)
        		at java.base/jdk.internal.misc.Unsafe.allocateInstance(Native Method)
        		at jdk.unsupported/sun.misc.Unsafe.allocateInstance(Unsafe.java:840)
        		at org.utbot.framework.util.EngineUtilsKt.getAnyInstance(EngineUtils.kt:35)
        		at org.utbot.framework.concrete.MockValueConstructor.constructObject(MockValueConstructor.kt:161)
        		at org.utbot.framework.concrete.MockValueConstructor.construct(MockValueConstructor.kt:127)
        		at org.utbot.framework.concrete.MockValueConstructor.mockAndGet(MockValueConstructor.kt:433)
        		at org.utbot.framework.concrete.MockValueConstructor.computeConcreteValuesForMethods(MockValueConstructor.kt:226)
        		at org.utbot.framework.concrete.MockValueConstructor.mockMethods(MockValueConstructor.kt:243)
        		at org.utbot.framework.concrete.MockValueConstructor.mockStaticMethods(MockValueConstructor.kt:265)
        		at org.utbot.framework.concrete.UtExecutionInstrumentation$invoke$$inlined$withReflection$lambda$1.invoke(UtExecutionInstrumentation.kt:155)
        		at org.utbot.framework.concrete.UtExecutionInstrumentation$invoke$$inlined$withReflection$lambda$1.invoke(UtExecutionInstrumentation.kt:107)
        		at org.utbot.framework.concrete.UtExecutionInstrumentation.withStaticFields(UtExecutionInstrumentation.kt:269)
        		at org.utbot.framework.concrete.UtExecutionInstrumentation.invoke(UtExecutionInstrumentation.kt:153)
        		at org.utbot.framework.concrete.UtExecutionInstrumentation.invoke(UtExecutionInstrumentation.kt:107)
        		at org.utbot.instrumentation.process.ChildProcessKt.loop(ChildProcess.kt:133)
        		at org.utbot.instrumentation.process.ChildProcessKt.main(ChildProcess.kt:77)
        		at org.utbot.instrumentation.process.ChildProcessKt.main(ChildProcess.kt)
        	 */

        // 1 occurrences of:
        // Concrete execution failed

    }
    ///endregion

    ///endregion

}

Environment

Jdk 8/11, Idea 2021.1 x64
image

@korifey korifey moved this to Todo in UTBot Java Aug 11, 2022
@alisevych alisevych added the ctg-bug Issue is a bug label Aug 15, 2022
@alisevych
Copy link
Member

Reproduced on the build from main on 8/15/2022
The differences in the current version of the plugin is that:

@SBOne-Kenobi
Copy link
Collaborator

On my laptop awt library was found in child process. ImageIO was tried to mock by symbolic engine but ImageIO was not instrumented. Concrete executor log.

  • need to research awt library location in IDEA or extend environment requirements with installing awt library
  • need to find out possibility of mocking awt classes

@alisevych alisevych added this to the Release preparation milestone Sep 7, 2022
@JaneEugenia JaneEugenia moved this from Todo to In Progress in UTBot Java Sep 8, 2022
@SBOne-Kenobi SBOne-Kenobi mentioned this issue Sep 8, 2022
6 tasks
@JaneEugenia JaneEugenia moved this from In Progress to Done in UTBot Java Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ctg-bug Issue is a bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants