GeezerVison is showing github.com — java.lang.UnsatisfiedLinkError: no awt in java.library.path · Issue #714 · UnitTestBot/UTBotJava
java.lang.UnsatisfiedLinkError: no awt in java.library.path #714
Description
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

Activity
alisevych commented on Aug 15, 2022
SBOne-Kenobi commented on Aug 18, 2022
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
Metadata
Metadata
StatusShow more project fields
Development
No branches or pull requestsIssue actions