Repository navigation
Closed
Labels
ctg-bugIssue is a bugspec-release-tailingsFailed to include in the current release, let's include it in the next one
Milestone
Description
Description
Test generation for Functional interfaces defined as class members - fails with InaccessibleObjectException from constructCompositeModel
To Reproduce
Steps to reproduce the behavior:
- Open IntelliJ IDEA
- Plugin is installed
- Create a new project with JDK 8
- Add a class LambdaVarExample (see below)
- Run test generation
- Repeat 3-5 steps for a project with JDK 11
import java.util.function.Predicate;
public class LambdaVarExample {
private Predicate<? super String> byCondition = l -> l.contains("b");
public void runTest(String input) {
if (byCondition.test(input)) {
firstScenario();
} else {
secondScenario();
}
}
private void firstScenario() {
System.out.println("1");
}
private void secondScenario() {
System.out.println("2");
}
}
Expected behavior
5-6. Tests are supposed to be generated without errors.
Actual behavior
An error test is generated with information about...
5. JDK 8 - ClassNotFoundException in concrete...
6. JDK 11 - InaccessibleObjectException in constructCompositeModel.
Visual proofs (screenshots, logs, images)
- JDK 8 error:
public void testRunTest_errors() {
// Couldn't generate some tests. List of errors:
//
// 1 occurrences of:
// Default concrete execution failed
// 1 occurrences of:
/* Error in the child process |> java.lang.ClassNotFoundException: jdk.internal.logger.SimpleConsoleLogger$CallerFinder
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at org.utbot.instrumentation.process.HandlerClassesLoader.loadClass(ChildProcess.kt:38)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at org.utbot.framework.concrete.MockValueConstructor.kClass(MockValueConstructor.kt:470)
at org.utbot.framework.concrete.MockValueConstructor.javaClass(MockValueConstructor.kt:455)
at org.utbot.framework.concrete.MockValueConstructor.constructObject(MockValueConstructor.kt:158)
at org.utbot.framework.concrete.MockValueConstructor.construct(MockValueConstructor.kt:127)
at org.utbot.framework.concrete.MockValueConstructor.constructObject(MockValueConstructor.kt:184)
at org.utbot.framework.concrete.MockValueConstructor.construct(MockValueConstructor.kt:127)
at org.utbot.framework.concrete.MockValueConstructor.constructMethodParameters(MockValueConstructor.kt:104)
at org.utbot.framework.concrete.UtExecutionInstrumentation.invoke(UtExecutionInstrumentation.kt:144)
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)
*/
}
- JDK 11 error:
public void testRunTest_errors() {
// Couldn't generate some tests. List of errors:
//
// 1 occurrences of:
/* Error in the child process |> java.lang.reflect.InaccessibleObjectException: Unable to make
field private boolean jdk.internal.logger.SimpleConsoleLogger$CallerFinder.lookingForLogger accessible: module java.base does not "opens
jdk.internal.logger" to unnamed module @29e6eb25
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:176)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:170)
at org.utbot.framework.concrete.UtModelConstructor.constructCompositeModel(UtModelConstructor.kt:356)
at org.utbot.framework.concrete.UtModelConstructor.constructFromAny(UtModelConstructor.kt:239)
at org.utbot.framework.concrete.UtModelConstructor.construct(UtModelConstructor.kt:107)
at org.utbot.framework.concrete.UtModelConstructor.constructCompositeModel(UtModelConstructor.kt:285)
at org.utbot.framework.concrete.UtModelConstructor.constructFromAny(UtModelConstructor.kt:239)
at org.utbot.framework.concrete.UtModelConstructor.construct(UtModelConstructor.kt:107)
at org.utbot.framework.concrete.UtExecutionInstrumentation$invoke$$inlined$withReflection$lambda$1.invoke(UtExecutionInstrumentation.kt:179)
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)
*/
}
Environment
Windows 10 Pro
IntelliJ IDEA 2022.1.3
JDK 8, 11
One of the latest plugin build: https://github.com/UnitTestBot/UTBotJava/actions/runs/2621106151
Metadata
Metadata
Assignees
Labels
ctg-bugIssue is a bugspec-release-tailingsFailed to include in the current release, let's include it in the next one
Type
Projects
- StatusShow more project fieldsDone
Activity
Damtev commentedon Oct 5, 2022
ClassNotFoundException, but gotDefault concrete execution failederror, which comes from fuzzer - @Markoutte take a look, please. Also, found wrong assertions from symbolic assertions (see the attached screenshot) - going to investigate.Default concrete execution failederror again - @Markoutte take a look too, please.Markoutte commentedon Oct 5, 2022
@Damtev looks like the problem that we cannot find lambda class to construct concrete "this" object. In this case the field cannot be created because Predicate uses a lambda. If we use anonymous class it works ok for fuzzer:
You can find the field gathering in
UtModelConstructor#constructCompositeModel:295: