Skip to content

Commit 9fa4da7

Browse files
committed
docs and ready to go
1 parent 0a2cf33 commit 9fa4da7

File tree

3 files changed

+45
-28
lines changed

3 files changed

+45
-28
lines changed

.github/copilot-instructions.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## What this project is
44

55
- A ColdBox module that embeds and exposes the JavaLoader library so CFML apps can dynamically load/compile Java classes and JARs.
6+
- On BoxLang 1.8.0+ the public loader facade uses BoxLang's native request class loader for dynamic class loading instead of instantiating the bundled JavaLoader.
67
- Key pieces: `ModuleConfig.cfc` (module settings & DSL registration), `models/Loader.cfc` (public module API), `models/javaloader/` (JavaLoader, JavaProxy, JavaCompiler implementations), and `test-harness/` (integration test app).
78

89
## Quick dev workflows (explicit)
@@ -26,13 +27,14 @@
2627

2728
- WireBox DSL: `ModuleConfig.cfc` registers a custom DSL `javaloader` via `wireBox.registerDSL(...)`. Use inject="javaloader:ClassName" for DSL injections.
2829
- Main WireBox mappings: `binder.map("jl@cbjavaloader")` (internal JavaLoader) and `loader@cbjavaloader` (public module proxy, see `models/Loader.cfc`). Use `getWireBox().getInstance("loader@cbjavaloader")` in tests or handlers.
29-
- Persistent loader instance: `models/Loader.cfc` stores the JavaLoader instance in `server` scope under a hashed static key and uses `lock` for safe init/re-init — avoid re-instantiating directly; call `Loader.setup(moduleSettings)` or `Loader.getJavaLoader()`.
30+
- Runtime split: `models/Loader.cfc` branches by runtime. On BoxLang it loads configured paths with `getRequestClassLoader().addPaths(...)` and resolves classes via `createObject( "java", className, getRequestClassLoader() )`. On Adobe CF/Lucee it stores the JavaLoader instance in `server` scope under a hashed static key and uses `lock` for safe init/re-init.
31+
- Module startup expands configured `loadPaths` into concrete files in `ModuleConfig.cfc`; `cfcdynamicproxy.jar` is prepended only for non-BoxLang runtimes.
3032
- Java compilation: `models/javaloader/JavaCompiler.cfc` expects a JVM `tools.jar` compiler on the classpath; compiled jars are placed by default in `models/javaloader/tmp` (see module `settings.compileDirectory`).
3133

3234
## Important files to consult (fast path)
3335

3436
- `ModuleConfig.cfc` — module settings defaults and DSL registration.
35-
- `models/Loader.cfc` — public API that other apps use (`create`, `appendPath`, `getLoadedURLs`).
37+
- `models/Loader.cfc` — public API that other apps use (`create`, `appendPaths`, `getLoadedURLs`) and the BoxLang/native-vs-JavaLoader branching.
3638
- `models/javaloader/JavaLoader.cfc` — upstream JavaLoader implementation (large file, primary behavior).
3739
- `models/javaloader/JavaCompiler.cfc` — dynamic compilation logic and compiler discovery.
3840
- `build/Build.cfc` and `box.json` — packaging, test runner URL and build scripts used by CI.
@@ -45,7 +47,9 @@
4547

4648
## Safety, edge cases, and constraints agents must respect
4749

48-
- Do not remove or replace the `server`-scoped loader without using the `Loader` API — other code/tests expect the single instance.
50+
- Do not remove or replace the `server`-scoped loader without using the `Loader` API on Adobe CF/Lucee — other code/tests expect the single instance there.
51+
- Do not assume a JavaLoader instance exists in `server` scope on BoxLang; the native path bypasses JavaLoader setup entirely.
52+
- When changing runtime-sensitive behavior, preserve the BoxLang vs Adobe CF/Lucee differences in `getLoadedURLs()`: BoxLang only reports configured app paths, while Adobe CF/Lucee also includes `cfcdynamicproxy.jar`.
4953
- Java compilation may fail when the JVM compiler is not available; surface clear errors and point to `JavaCompiler.cfc` and `tools.jar` classpath as remediation.
5054

5155
## Examples (from repo)
@@ -60,7 +64,7 @@
6064

6165
## What to do next when editing code
6266

63-
- When changing public behavior in `Loader.cfc` or DSL registration in `ModuleConfig.cfc`, update `test-harness/tests/specs/LoaderTest.cfc` or add a spec demonstrating the change.
67+
- When changing public behavior in `Loader.cfc` or DSL registration in `ModuleConfig.cfc`, update `test-harness/tests/specs/LoaderTest.cfc` or add a spec demonstrating the change, including runtime-specific expectations when BoxLang behavior differs from Adobe CF/Lucee.
6468
- Run `box testbox ...` after edits and ensure `test-harness` runner URL in `box.json` matches `build/Build.cfc` test runner if you rely on build tasks.
6569

6670
Please review and tell me if you'd like added examples (e.g., a minimal handler that uses the loader), or if I should fold in more lines from the module-template instructions.

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased]
1111

12+
### Added
13+
14+
- Native BoxLang 1.8.0+ dynamic class loading support through the request class loader.
15+
16+
### Changed
17+
18+
- `loader@cbjavaloader` now skips JavaLoader initialization on BoxLang and loads configured `loadPaths` directly into the native request class loader.
19+
- BoxLang startup no longer prepends `cfcdynamicproxy.jar`, so `getLoadedURLs()` differs from Adobe CF and Lucee runtimes.
20+
1221
## [2.3.0] - 2025-08-23
1322

1423
## [2.2.0] - 2025-02-19

readme.md

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<p align="center">
2-
<img src="https://www.ortussolutions.com/__media/coldbox-185-logo.png">
2+
<img src="https://www.ortussolutions.com/__media/coldbox-185-logo.png" alt="ColdBox logo">
33
<br>
4-
<img src="https://www.ortussolutions.com/__media/wirebox-185.png" height="125">
5-
<img src="https://www.ortussolutions.com/__media/cachebox-185.png" height="125" >
6-
<img src="https://www.ortussolutions.com/__media/logbox-185.png" height="125">
4+
<img src="https://www.ortussolutions.com/__media/wirebox-185.png" height="125" alt="WireBox logo">
5+
<img src="https://www.ortussolutions.com/__media/cachebox-185.png" height="125" alt="CacheBox logo">
6+
<img src="https://www.ortussolutions.com/__media/logbox-185.png" height="125" alt="LogBox logo">
77
</p>
88

99
<p align="center">
@@ -15,13 +15,9 @@
1515

1616
----
1717

18-
# Welcome to the cbJavaloader Project
18+
# Welcome to cbJavaLoader
1919

20-
<a href="https://github.com/coldbox-modules/cbjavaloader/actions/workflows/ci.yml">
21-
<img src="https://github.com/coldbox-modules/cbjavaloader/actions/workflows/ci.yml/badge.svg">
22-
</a>
23-
24-
This module will allow your ColdBox applications to class load different Java classes and libraries at runtime via the JavaLoader project. It also registers a WireBox DSL so you can easily inject Java classes into your objects using WireBox.
20+
This module allows your ColdBox applications to class load different Java classes and libraries at runtime. On Adobe ColdFusion and Lucee it uses the bundled JavaLoader project. On BoxLang 1.8.0+ it uses BoxLang's native request class loader while keeping the same `loader@cbjavaloader` facade and `javaloader:` WireBox DSL.
2521

2622
## License
2723

@@ -36,9 +32,9 @@ Apache License, Version 2.0.
3632

3733
## System Requirements
3834

39-
- BoxLang 1+
35+
- BoxLang 1.8.0+
4036
- Lucee 5+
41-
- ColdFusion 2021+
37+
- Adobe ColdFusion 2023+
4238

4339
## Instructions
4440

@@ -48,13 +44,22 @@ Just drop into your **modules** folder or use the box-cli to install
4844

4945
The module has a default folder called `lib` where any jars you drop there will be class loaded automatically. However, we recommend using the `loadpaths` setting for selecting an array of locations to class load, so when the module updates you won't lose those files.
5046

51-
## Models
47+
On BoxLang 1.8.0+ those configured paths are added to the native request class loader. On Adobe ColdFusion and Lucee they continue to be loaded through JavaLoader.
48+
49+
## Loader API
5250

53-
The module registers the following mapping in WireBox: `loader@cbjavaloader`. Which is the class you will use to class load, append paths and much more. Check out the included API Docs for much more information. The main methods of importance of the java loader are:
51+
The module registers the following mapping in WireBox: `loader@cbjavaloader`. This is the facade you will use to class load, append paths, and inspect the active class loader. The main methods are:
5452

5553
- `create( class )` - Create a loaded Java class
56-
- `appendPath( dirPath, filter)` - Appends a directory path of *.jar's,*.classes to the current loaded class loader.
54+
- `appendPaths( dirPath, filter )` - Appends a directory path of `*.jar` or `*.class` files to the current class loader.
5755
- `getLoadedURLs()` - Get all the loaded URLs
56+
- `getURLClassLoader()` - Get the active class loader implementation
57+
58+
## Runtime Behavior
59+
60+
- BoxLang 1.8.0+: `loader@cbjavaloader` uses the native request class loader. `setup()` and `appendPaths()` call `addPaths()`, and `create()` resolves classes with `createObject( "java", className, getRequestClassLoader() )`.
61+
- Adobe ColdFusion and Lucee: the module keeps using the bundled JavaLoader instance stored in server scope, including the legacy `cfcdynamicproxy.jar` support jar.
62+
- Because of that runtime split, `getLoadedURLs()` will usually report fewer entries on BoxLang than on Adobe ColdFusion or Lucee for the same configuration.
5863

5964
## WireBox DSL
6065

@@ -71,26 +76,27 @@ property name="buffer" inject="javaloader:org.class.path.StringBuffer";
7176
Here are the module settings you can place in your `ColdBox.cfc` under an `moduleSettings.cbJavaLoader` structure:
7277

7378
```js
74-
7579
moduleSettings = {
7680
cbJavaLoader = {
7781
// A single path, and array of paths or a single Jar
7882
loadPaths = [],
79-
// Load ColdFusion classes with loader
83+
// Load ColdFusion classes with loader (JavaLoader runtimes only)
8084
loadColdFusionClassPath = false,
81-
// Attach a custom class loader as a parent
85+
// Attach a custom class loader as a parent (JavaLoader runtimes only)
8286
parentClassLoader = "",
83-
// Directories that contain Java source code that are to be dynamically compiled
87+
// Directories that contain Java source code that are to be dynamically compiled (JavaLoader runtimes only)
8488
sourceDirectories = [],
85-
// the directory to build the .jar file for dynamic compilation in, defaults to ./tmp
89+
// the directory to build the .jar file for dynamic compilation in, defaults to ./tmp (JavaLoader runtimes only)
8690
compileDirectory = "models/javaloader/tmp",
87-
// Whether or not the source is trusted, i.e. it is going to change? Defaults to false, so changes will be recompiled and loaded
91+
// Whether or not the source is trusted, i.e. it is going to change? Defaults to false, so changes will be recompiled and loaded (JavaLoader runtimes only)
8892
trustedSource = false
8993
}
9094
};
9195

9296
```
9397

98+
In BoxLang native mode, `loadPaths` is the primary setting used by the loader facade. The remaining compilation and parent-loader settings continue to apply to the JavaLoader-backed Adobe ColdFusion and Lucee path.
99+
94100
Below is a simple example:
95101

96102
```js
@@ -116,12 +122,10 @@ component{
116122
}
117123
```
118124

119-
---
125+
----
120126

121-
********************************************************************************
122127
Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
123128
www.ortussolutions.com
124-
********************************************************************************
125129

126130
### HONOR GOES TO GOD ABOVE ALL
127131

0 commit comments

Comments
 (0)