Unfortunately the bundled Java Version 17 with Col...
# adobe
h
Unfortunately the bundled Java Version 17 with ColdFusion2023 causes an issue in our function to read Java properties files.
Copy code
// create java objects to read bundle
		var oI18N = CreateObject("java", "java.util.PropertyResourceBundle");
		var oFis = CreateObject("java", "java.io.FileInputStream");
Copy code
sResourceFilePath = arguments.sBundlePath & arguments.sBundle & "_" & variables.sLang & ".properties";
Copy code
if (fileExists(sResourceFilePath)) {
			bIsOk=true;
			oFis.init(sResourceFilePath);
			oI18N.init(oFis);
***			keys=oI18N.getKeys();
            ...
		}
Error: java.lang.reflect.InaccessibleObjectException: Unable to make public sun.util.ResourceBundleEnumeration(java.util.Set,java.util.Enumeration) accessible: module java.base does not "exports sun.util" to unnamed module @62b6c045 I checked also @bdw429s https://www.forgebox.io/view/propertyFile which has another issue: Object Instantiation Exception. Class not found: org.apache.commons.io.input.BOMInputStream The error occurred in D/projekte cf/PropertyFile.cfc line 28 Called from D/projekte cf/test propertyfile.cfm line 2 Called from D/projekte cf/PropertyFile.cfc line 28 Called from D/projekte cf/test propertyfile.cfm line 2
Copy code
26 : 		setPath( arguments.path );
27 : 		var fis = CreateObject( 'java', 'java.io.FileInputStream' ).init( path );
28 : 		var BOMfis = CreateObject( 'java', 'org.apache.commons.io.input.BOMInputStream' ).init( fis );
29 : 		var propertyFile = getJavaPropertyFile();
30 : 		propertyFile.load( BOMfis );
An ugly alternative would be to use ColdFusion, see https://cflib.org/udf/readPropertiesFile But I guess there must be a better way to load properties files with Adobe ColdFusion 2023 and Java 17?
b
@harryk you just need to add those opens as jvm args
Adobe basically added a bunch if ines they found during testing, but there will always be missing ones
h
Thanks, but not sure how to do that. How would this jvm argument look like?
s
(FWIW, we run a lot of complex apps on the JVM without adding options to open modules so I consider them very much a workaround and a bit of an infrastructure "smell")
b
@harryk Google is your friend 😉
And yes, Sean is correct, it's a total workaround. Java has made it clear, the manner in which CF uses reflection is not how they want Java used going forward.
I've spoken with both CF engines about using more modern approaches like invokedynamic, but I've been ignored.
@harryk I'd start with something like
Copy code
--add-exports java.base/sun.util=ALL-UNNAMED
as a JVM arg
👍 2
I actually add that one automatically in CommandBox when starting servers
And regarding the error you hit on the propertyFile library, it appears I'm assuming the apache commons IO library to exist on the classpath which Lucee uses, but it seems ACF does not 😕
That class isn't strictly required, but it strips off any BOM found on the properties file, which I've found to be common when using modern IDEs to edit the file