@@ -27,6 +27,18 @@ component accessors="true" singleton {
2727 * Setup class loading
2828 */
2929 function setup ( required struct moduleSettings ){
30+ // BoxLang 1.8.0+: use native class loading, skip JavaLoader entirely
31+ if ( isBoxLangNative () ) {
32+ var loadPaths = arguments .moduleSettings .loadPaths ?: [];
33+ if ( ! isArray ( loadPaths ) ) {
34+ loadPaths = listToArray ( loadPaths );
35+ }
36+ if ( arrayLen ( loadPaths ) ) {
37+ getRequestClassLoader ().addPaths ( loadPaths );
38+ }
39+ return ;
40+ }
41+
3042 // verify we have it loaded
3143 if ( not isJavaLoaderInScope () ) {
3244 lock name = " #variables .staticIDKey #" throwontimeout = " true" timeout = " 30" type = " exclusive" {
@@ -55,6 +67,9 @@ component accessors="true" singleton {
5567 * Retrieves a reference to the java class. To create a instance, you must run init() on this object
5668 */
5769 function create ( required string className ){
70+ if ( isBoxLangNative () ) {
71+ return createObject ( " java" , arguments .className , getRequestClassLoader () );
72+ }
5873 return getJavaLoaderFromScope ().create ( argumentCollection = arguments );
5974 }
6075
@@ -65,6 +80,15 @@ component accessors="true" singleton {
6580 * @filter.hint The directory filter
6681 */
6782 function appendPaths ( required string dirPath , string filter = " *.jar" ){
83+ // BoxLang 1.8.0+: use native class loading
84+ if ( isBoxLangNative () ) {
85+ var newPaths = arrayOfJars ( argumentCollection = arguments );
86+ if ( arrayLen ( newPaths ) ) {
87+ getRequestClassLoader ().addPaths ( newPaths );
88+ }
89+ return ;
90+ }
91+
6892 // Convert paths to array of file locations
6993 var qFiles = arrayOfJars ( argumentCollection = arguments );
7094 var iterator = qFiles .iterator ();
@@ -99,6 +123,16 @@ component accessors="true" singleton {
99123 * Get all the loaded URLs
100124 */
101125 array function getLoadedURLs (){
126+ // BoxLang 1.8.0+: get URLs directly from the request class loader
127+ if ( isBoxLangNative () ) {
128+ var loadedURLs = getRequestClassLoader ().getURLs ();
129+ var returnArray = arrayNew ( 1 );
130+ for ( var url in loadedURLs ) {
131+ arrayAppend ( returnArray , url .toString () );
132+ }
133+ return returnArray ;
134+ }
135+
102136 var loadedURLs = getURLClassLoader ().getURLs ();
103137 var returnArray = arrayNew ( 1 );
104138 var x = 1 ;
@@ -114,14 +148,22 @@ component accessors="true" singleton {
114148 * Returns the java.net.URLClassLoader in case you need access to it
115149 */
116150 any function getURLClassLoader (){
151+ // BoxLang 1.8.0+: return the native request class loader
152+ if ( isBoxLangNative () ) {
153+ return getRequestClassLoader ();
154+ }
117155 return getJavaLoaderFromScope ().getURLClassLoader ();
118156 }
119157
120158 /**
121159 * Get the Javaloader Version
122160 */
123161 string function getVersion (){
124- return getJavaLoaderFromScope ().getVersion ();
162+ if ( isJavaLoaderInScope () ) {
163+ return getJavaLoaderFromScope ().getVersion ();
164+ }
165+ // BoxLang native mode: JavaLoader is not in scope; return the same version string
166+ return " 1.2" ;
125167 }
126168
127169 /**
@@ -160,4 +202,11 @@ component accessors="true" singleton {
160202 return structKeyExists ( server , getstaticIDKey () );
161203 }
162204
205+ /**
206+ * Detects whether we are running on BoxLang, which always supports native dynamic class loading.
207+ */
208+ private boolean function isBoxLangNative (){
209+ return structKeyExists ( server , " boxlang" );
210+ }
211+
163212}
0 commit comments