tkobayas commented on code in PR #6587:
URL: 
https://github.com/apache/incubator-kie-drools/pull/6587#discussion_r3233069588


##########
kie-memory-compiler/src/main/java/org/kie/memorycompiler/jdknative/NativeJavaCompiler.java:
##########
@@ -87,6 +93,10 @@ public CompilationResult compile( String[] pResourcePaths,
         DiagnosticCollector<JavaFileObject> diagnostics = new 
DiagnosticCollector<>();
         JavaCompiler compiler = getJavaCompiler();
 
+        if (pResourcePaths == null || pResourcePaths.length == 0) {
+            return new CompilationResult( new CompilationProblem[0] );
+        }

Review Comment:
   done



##########
kie-memory-compiler/src/test/java/org/kie/memorycompiler/jdknative/NativeJavaCompilerTest.java:
##########
@@ -40,15 +55,152 @@ public void simulateJreWithException() {
 
                
assertThatExceptionOfType(KieMemoryCompilerException.class).isThrownBy(() -> 
compiler.compile(null, null, null, null, null));
        }
-       
+
+       @Test
+       public void emptySourcesShouldSucceed() {
+               NativeJavaCompiler compiler = new NativeJavaCompiler();
+               CompilationResult result = compiler.compile(new String[0], 
null, null, null, compiler.createDefaultSettings());
+               assertThat(result.getErrors()).isEmpty();
+       }
+
+       /**
+        * Tests that NativeJavaCompiler can resolve classes from 
directory-based
+        * classpath entries (not JARs). This exercises the processDirectory() 
method
+        * which was added to fix kjar builds where kie-maven-plugin compiles 
DRL
+        * referencing Java classes from target/classes.
+        *
+        * The test compiles source that references CompilationResult (a class 
from
+        * this module's target/classes directory) using a URLClassLoader that 
includes
+        * target/classes as a directory URL — without setting any classpath on
+        * JavaCompilerSettings (simulating the classic DRL compilation path).
+        */
+       @Test
+       public void compileWithDirectoryClasspath() throws Exception {
+               // target/classes contains compiled classes from this module as 
a directory (not a JAR)
+               File targetClasses = new File("target/classes");
+               assertThat(targetClasses).isDirectory();
+
+               // Create a classloader with target/classes as a directory URL

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to