JavaLoader icon indicating copy to clipboard operation
JavaLoader copied to clipboard

Dynamic Compilation that includes import statements

Open Brookd23 opened this issue 6 years ago • 1 comments

I am trying to compile a java file (https://github.com/mkl-public/testarea-itext7/blob/master/src/main/java/mkl/testarea/itext7/extract/TextPlusYExtractionStrategy.java) , but the imports are not working and throw errors:

` import com.itextpdf.kernel.geom.Vector;

import com.itextpdf.kernel.pdf.canvas.parser.listener.LocationTextExtractionStrategy;

import com.itextpdf.kernel.pdf.canvas.parser.listener.TextChunk; `

But I get errors like:

error: cannot find symbol public class TextPlusYExtractionStrategy extends LocationTextExtractionStrategy ^ symbol: class LocationTextExtractionStrategy

The itext7 jars are included in the loadPaths provided to the JavaLoader.. and are available if manually instantiated via create() but the import statements on a dynamic compile doesn't seem to be able to find them.. any ideas?

Brookd23 avatar Oct 17 '19 23:10 Brookd23

Ok, so I tried putting all the itext7 JARS in the coldfusion\lib directory. I can see that they are now all loaded. I added loadColdFusionClassPath=true to the javaloader, and tried to compile this java file with the import statements, hoping those classes would now be available - but now I get the error below. I am on Java 11 on CF2016. Any thoughts?

` java.lang.reflect.InaccessibleObjectException: Unable to make public void jdk.internal.loader.BuiltinClassLoader.loadModule(java.lang.module.ModuleReference) accessible: module java.base does not "exports jdk.internal.loader" to unnamed module @655871e

`

Brookd23 avatar Oct 18 '19 00:10 Brookd23