Skip to content

LDEV-6763 COM extension: createComObject, releaseComObject (Jacob 1.21) - #1

Merged
michaeloffner merged 9 commits into
mainfrom
LDEV-6763-com-extension
Oct 30, 2026
Merged

michaeloffner merged 9 commits into
mainfrom
LDEV-6763-com-extension

Conversation

@michaeloffner

@michaeloffner michaeloffner commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

First version of the COM extension, part of LDEV-6763 (Lucee 9 epic LDEV-6590). The COM support (Jacob) is removed from the Lucee core in lucee/Lucee#3402 (merged into 9.0 builds, so 9.0 has no COM until this is released) and moves here.

What it is

  • createComObject( className ) and releaseComObject( comObject ) (replace createObject("com", ...) / <cfobject type="com"> and the core function releaseComObject)
  • Jacob 1.21 from Maven Central (io.github.osobolev:jacob), instead of the old fork in the core. The native libraries jacob-1.21-x64.dll / jacob-1.21-x86.dll of the same release are downloaded from Central at build time (nothing binary is committed, checksums in the README), packaged as resources of the extension jar and copied to lucee-server/bin on first use (DllSetup, respects jacob.dll.path, replaces a stale file, com.jacob.autogc=true).
  • The extension is not required by Lucee (not in Require-Extension), installed on demand.
  • Written against the loader API (CFMLEngine utils), SimpleDumpData (a core class) is created by reflection for the dump.
  • Based on the layout of extension-markdown (pom.xml + build.xml + source/java/pom.xml, lite and full .lex).

Tested

  • Builds a .lex (full 282 KB incl. Jacob, lite without maven folder), installed it into the Lucee 9 single jar (PR LDEV-6711 single jar: root pom builds loader and core as one jar Lucee#3357): the functions are found, createComObject throws "COM objects are only supported on Windows" on macOS, releaseComObject ignores non COM objects.
  • tests/createComObject.cfc run with script-runner on macOS: the platform independent specs pass, the Windows specs are skipped. The Windows specs (Scripting.Dictionary, WScript.Shell, Scripting.FileSystemObject incl. dates, enumeration and COM objects as arguments, unknown ProgID, many objects) run in the new test-windows job. They were written without a Windows machine, the first CI run is their first run.
  • The workflow follows extension-redis (CI friendly version from extension.version.base / qualifier, automatic build number, deploy / qualifier inputs, deploy only on push to main or manual, GitHub release, S3), plus the "Resolve Lucee test matrix" fallback (7.0, 7.1, 8.0, 9.0).

Open

  • source/images/logo.png is a placeholder (solid colour), needs a real logo
  • the extension id 221842AA-DCBB-49DE-ADF0E2A28B7F58AC is new, the extension has to be registered at the extension provider after the first release
  • luceeCoreVersion is 7.0.0.395 (the loader API is enough, so code can be migrated before the upgrade; 7.x/8.0 still have COM in the core, there the extension is redundant), introduced of createComObject is 9.0.0.0

@GianTschingt GianTschingt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pulling this out of core, the structure is clean and the diff against the old core code is small. I'm not approving yet, mainly because of the build/release side and because nothing exercises the COM code on Windows. Grouped by priority:

Must-fix

  1. Jacob dependency is not resolvable from Maven Central. com.jacob:jacob:1.21 is installed from source/java/lib by the install-jacob target (source/java/pom.xml:175-181). That works inside this build, but the published org.lucee:com POM (and so the lite .lex, or maven="org.lucee:com:..." installs) will reference an artifact that Central doesn't have. Only the full .lex carries the jar in its maven/ folder. io.github.osobolev:jacob:1.21 is on Central (jar plus the x86/x64 DLLs), and the committed jar/DLLs here have different checksums than those, so please either (a) switch to that coordinate, or (b) shade Jacob into the extension jar, or (c) document exactly where the committed binaries come from. If (c), please add their SHA-256 values and the upstream source tag to the README.
  2. Release workflow doesn't follow the standard release action (see extension-redis .github/workflows/main.yml): no deploy / qualifier workflow_dispatch inputs, no automatic build number (highest of git tags + Central/snapshot metadata + 1), no concurrency group, version is a hardcoded 1.0.0.1-ALPHA instead of extension.version.base + extension.version.qualifier. The deploy job (main.yml:96-139) also runs on every event including pull_request, and the first non-ALPHA/SNAPSHOT version would go to mvn deploy from PRs. Gate it like redis (DO_DEPLOY only for push to the default branch or manual deploy, and skip when the secrets are empty).
  3. Test matrix has no fork fallback (main.yml:48): fromJSON(vars.LUCEE_TEST_VERSIONS_7) fails on fork PRs where the variable is empty. Please add the "Resolve Lucee test matrix" step (variable if set, otherwise latest 7.0/7.1/8.0 all/light, and 9.0 as required line since that is where core no longer ships COM).
  4. Nothing runs the COM code. CI is ubuntu-latest only, so tests/createComObject.cfc only proves the "Windows only" error path. Please add a windows-latest job (JDK 21, same script-runner step) with real tests, e.g. Scripting.Dictionary (Add/Item/Count/Exists, Keys() array, for (k in dict)), WScript.Shell (ExpandEnvironmentStrings("%windir%")), Scripting.FileSystemObject (GetFile(path).DateLastModified, folder Files enumeration, passing a COMObject as an argument), releaseComObject, and unknown ProgID. The date check would catch the issue in the inline comment on COMUtil.java:37.
  5. PR description still says lucee/Lucee#TBD. The core PR is merged as lucee/Lucee#3402 (9.0), so 9.0 builds now have no COM at all until this is released. Please link it.

Should-fix

  • Thread/resource handling. Jacob initialises each thread as MTA implicitly on the first object (ROT.addObject), but nothing in the extension (or the old core code) ever calls ComThread.Release(). The per-thread table keeps strong references to every Variant/Dispatch created on that thread (a HashMap unless -Dcom.jacob.autogc=true), so a request thread that touches COM in a loop holds on to everything for the life of the thread, and COMObject.release() (COMObject.java:203) only frees that one dispatch. Options: set com.jacob.autogc=true before the first Jacob class loads (in DllSetup), and/or release at request end. Please at least document it, and ideally add a Windows test that creates many objects. Also worth a sentence in the README that objects live in the MTA, legacy STA-only components may need more.
  • ComFailException leaks as a raw runtime exception. new Dispatch(name) for an unregistered ProgID (COMObject.java:48) throws a bare com.jacob.com.ComFailException; please catch it and rethrow an application exception that includes the ProgID and the HRESULT message. get(pc, key, defaultValue) and setEL (COMObject.java:66-68, 77-80) call Jacob outside any try, so isNull(obj.missing) / obj.missing ?: x throw instead of returning the default.
  • DllSetup: (a) System.setProperty(jacob.dll.path/name) (DllSetup.java:60-61) overrides a value the admin set on purpose, please respect an existing jacob.dll.path; (b) an existing file is accepted if it is non-empty (:43), so a truncated or stale file with the right name is never replaced, compare size or hash with the bundled resource; (c) delete the temp file in a finally (:48-57), and include the target path in the failure message so a read-only bin folder is easy to diagnose; (d) a JNI library can only be loaded by one classloader per JVM, so after an extension update/reload without a server restart System.load will most likely fail with "already loaded in another classloader", worth a clear message/doc; (e) getJREArch() is only x86 or x64, on a Windows ARM64 JVM it will pick the x64 DLL, which should at least fail with a readable message; (f) done is read outside the lock, make it volatile.
  • Version/baseline. luceeCoreVersion and the lucee dependency are 7.0.0.395 (pom.xml:23, source/java/pom.xml:185) while the extension is meant to replace core COM in 9.0. Please confirm which minimum is intended (7.0/7.1/8.0 still ship their own COM, so installing it there is at best redundant) and that the extension metadata and the README say the same.
  • Licence. License.txt and the bundled resources/jacob/LICENSE.TXT are there, but since LGPL code and binaries are redistributed, add a short NOTICE/README section naming Jacob 1.21 (LGPL), the upstream source location, and that the bundled library can be replaced (LGPL terms). It also covers point 1.
  • Docs. Add the breaking changes to the README: createObject("com", ...) and <cfobject type="com"> are replaced by createComObject(), and exception class names change (lucee.commons.jacob.com.* from core vs com.jacob.com.*), which matters for anyone catching by type.

Nice-to-have

  • Cache the SimpleDumpData constructor (COMObject.java:113-121). The reflection is understandable since the class isn't part of the loader API, but a failure there shouldn't turn a dump() into a runtime exception; fall back to a plain text row.
  • remove() in the iterators (COMKeyWrapperIterator.java:28, COMValueWrapperIterator.java:21, COMObject.java:231/259) releases the enumerator instead of throwing UnsupportedOperationException, and next() at the end of the enumeration gives an NPE (enumVariant.Next() returns null) instead of NoSuchElementException. Release the EnumVariant once it's exhausted.
  • COMObject.iterator() (:207) is missing @Override; double check the extension id 221842AA-DCBB-49DE-ADF0E2A28B7F58AC is new (not copied from another extension).

Happy to re-review once the build side and Windows tests are in. The code itself looks close.

Comment thread source/java/pom.xml Resolved
Comment thread .github/workflows/main.yml Resolved
Comment thread .github/workflows/main.yml Resolved
…kflow like the other extensions with matrix fallback and a Windows job, DllSetup, COM exceptions, iterators, date and currency conversion, tests, README
…pdate provider serves it, luceeCoreVersion 7.0.5.41
…M support of the core of Lucee 7/8: set them only while the library is loaded, own property for a custom library
… of the Lucee core (LDEV3314 fails on Windows with 8.0 without being related to the extension)
…tead of testFilter (testFilter matched nothing on Windows)
… (Dictionary.Keys, Item), the message names the vt value, no loop over a collection of COM objects in the test
@michaeloffner

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Status of the points of the review summary (the inline threads are answered and resolved):

Must-fix

  1. Jacob: io.github.osobolev:jacob:1.21 from Central, the DLLs of the same release are downloaded from Central at build time, nothing binary is committed, SHA-256 values in the README.
  2. Release workflow: follows extension-redis (deploy / qualifier inputs, automatic build number, concurrency, DO_DEPLOY only for a push to main or a manual deploy with the secrets, version from extension.version.base + qualifier, GitHub release, S3).
  3. Test matrix: new setup job with the "Resolve Lucee test matrix" fallback. 9.0 is not in the fallback yet because the update provider does not serve 9.0 builds (latest/9.0/all/light answers 404), the line is prepared in REQUIRED_LINES.
  4. Windows tests: test-windows job with real COM tests (Scripting.Dictionary, WScript.Shell, Scripting.FileSystemObject incl. dates, COM objects as arguments, unknown ProgID, 300 objects, dump). They run now and pass on 7.0.5.41, 7.1 and 8.0. The first Windows runs found two real problems that are fixed: values returned by reference and arrays (Dictionary.Keys(), Item()) were not converted, and the test paths. Note: the tests are selected with their own label comextension, so the COM tests of the Lucee test suite (label com, e.g. LDEV3314 which tests the core COM of 7/8) are not run here.
  5. PR description: linked to LDEV-6763 move COM support (Jacob) to the COM extension Lucee#3402 (merged).

Should-fix

  • Threads / resources: com.jacob.autogc=true is set before the first Jacob class is used (unless already set), README documents MTA and releaseComObject. Not done: a test that proves the table does not grow, the 300 objects test only proves it works.
  • ComFailException: caught everywhere, application exception with ProgID / name and the Windows message; get with a default and setEL do not throw.
  • DllSetup (a)-(f): done, with one change from the first fix: the global properties jacob.dll.path / jacob.dll.name are only set while the library is loaded and then set back, because the COM support of the core of Lucee 7/8 uses the same properties for its own DLL (installing the extension there broke the core COM). A custom library is configured with lucee.extension.com.dll.path.
  • Baseline: luceeCoreVersion is 7.0.5.41 (the first 7.0 builds could not load the extension class reliably in CI), the README says so: works from 7.0.5.41, redundant on 7.x/8.0 which still have COM in the core, required from 9.0.
  • Licence: README section with Jacob 1.21, upstream sources, LGPL and how to replace the library.
  • Docs: README has the migration and the exception class names.

Nice-to-have: SimpleDumpData constructor cached with a fallback, iterators (remove(), release, NoSuchElementException) done; @Override on iterator() is not possible (not declared by an interface of the loader API); the extension id is a new UUID (checked, not used by another extension in my checkouts).

All checks are green, including the three Windows jobs. Ready for another look.

@GianTschingt GianTschingt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all points from my review are addressed: Jacob 1.21 from Maven Central with the DLLs fetched at build time, the release workflow follows the standard one, real Windows tests (including the date check), the exception and DllSetup fixes, and the README covers the migration and the licence. Looks good to me.

One small follow-up I'd do separately: add 9.0 to the test matrix, now that LUCEE_TEST_VERSIONS_9 and the LUCEE_MAVEN_URL fallback exist, since 9.0 is the line where the core no longer has COM.

@michaeloffner
michaeloffner merged commit 27cde85 into main Oct 30, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants