From c69ebfc989b1b2a2a51e532bb466243de036ba94 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Sat, 22 Aug 2026 20:27:23 -0600 Subject: [PATCH] fix: initialize JavaLoader with full null support --- .github/workflows/tests.yml | 5 +++++ models/javaloader/JavaLoader.cfc | 4 ++-- test-harness/tests/full-null/Application.cfc | 11 +++++++++++ test-harness/tests/full-null/loader.cfm | 9 +++++++++ test-harness/tests/specs/LoaderTest.cfc | 8 ++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 test-harness/tests/full-null/Application.cfc create mode 100644 test-harness/tests/full-null/loader.cfm diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6c1afca..d14ed4d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -83,6 +83,11 @@ jobs: box server start serverConfigFile="server-${{ matrix.cfengine }}.json" --noSaveSettings --debug curl http://127.0.0.1:60299 + - name: Run Adobe Full Null Regression + if: ${{ matrix.cfengine == 'adobe@2023' }} + run: | + curl --fail-with-body http://127.0.0.1:60299/tests/full-null/loader.cfm + - name: Run Tests run: | mkdir -p test-harness/tests/results diff --git a/models/javaloader/JavaLoader.cfc b/models/javaloader/JavaLoader.cfc index 15c0316..a078bef 100644 --- a/models/javaloader/JavaLoader.cfc +++ b/models/javaloader/JavaLoader.cfc @@ -78,7 +78,7 @@ loadClasses(); - if ( structKeyExists( arguments, "sourceDirectories" ) AND arrayLen( arguments.sourceDirectories ) ) { + if ( !isNull( arguments.sourceDirectories ) AND arrayLen( arguments.sourceDirectories ) ) { setJavaCompiler( createObject( "component", "JavaCompiler" ).init( arguments.compileDirectory ) ); setSourceDirectories( arguments.sourceDirectories ); setCompileDirectory( arguments.compileDirectory ); @@ -567,7 +567,7 @@ name ="initUseJavaProxyCFC" hint ="initialise whether or not to use the JavaProxy CFC instead of the coldfusion java object" access ="private" - returntype="string" + returntype="void" output ="false" > diff --git a/test-harness/tests/full-null/Application.cfc b/test-harness/tests/full-null/Application.cfc new file mode 100644 index 0000000..e063d04 --- /dev/null +++ b/test-harness/tests/full-null/Application.cfc @@ -0,0 +1,11 @@ +component { + + moduleRoot = createObject( "java", "java.io.File" ) + .init( getDirectoryFromPath( getCurrentTemplatePath() ) & "../../../" ) + .getCanonicalPath(); + + this.name = "cbjavaloader-full-null-regression-#hash( moduleRoot )#"; + this.enableNullSupport = true; + this.mappings[ "/cbjavaloader" ] = moduleRoot; + +} diff --git a/test-harness/tests/full-null/loader.cfm b/test-harness/tests/full-null/loader.cfm new file mode 100644 index 0000000..1e54b3f --- /dev/null +++ b/test-harness/tests/full-null/loader.cfm @@ -0,0 +1,9 @@ + +loader = new cbjavaloader.models.javaloader.JavaLoader().init(); + +if ( !isArray( loader.getClassLoadPaths() ) || !isInstanceOf( loader.getURLClassLoader(), "java.lang.ClassLoader" ) ) { + throw( type = "RegressionFailure", message = "The public loader did not initialize." ); +} + +writeOutput( "PASS" ); + diff --git a/test-harness/tests/specs/LoaderTest.cfc b/test-harness/tests/specs/LoaderTest.cfc index a04bf25..b1ff012 100644 --- a/test-harness/tests/specs/LoaderTest.cfc +++ b/test-harness/tests/specs/LoaderTest.cfc @@ -30,6 +30,14 @@ component extends="coldbox.system.testing.BaseTestCase" appMapping="/root" { expect( loader ).toBeComponent(); } ); + it( "should initialize the public loader API with full null support", function(){ + var loader = new cbjavaloader.models.javaloader.JavaLoader().init(); + + expect( loader ).toBeComponent(); + expect( loader.getClassLoadPaths() ).toBeArray().toBeEmpty(); + expect( loader.getURLClassLoader() ).toBeInstanceOf( "java.lang.ClassLoader" ); + } ); + it( "should class load jar files", function(){ var event = execute( "main.index" ); var prc = event.getCollection( private = true );