Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable std-database in native image #12068

Merged
merged 19 commits into from
Jan 26, 2025
Merged

Conversation

hubertp
Copy link
Collaborator

@hubertp hubertp commented Jan 16, 2025

Pull Request Description

enso --run test/Table_Tests passes without failures.
Used the opportunity to cleanup resource configs a bit and update them for each of standard libraries (not yet complete but almost).

Closes #12006 and #12018

Important Notes

We include java.desktop module now, which is unfortunate but necessary for java.beans and java.awt.
But we also use NI substitution which workarounds current java.awt limitations.

More importantly, Language Server's NI continues to work.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.

Not working ATM, breaks even BASE stdlib tests.
Culprit appears to be `sqlite-jdbc` client
sqlite-jdbc's NI properties file defines
`--enable-url-protocols=jar`. That's experimental and breaks completely
our `HostClassloader`. We exclude their config but include their feature
to correctly extract shared native library.
Excel_Spec leads to segfault, potentially related to reading/writing
files.
@hubertp
Copy link
Collaborator Author

hubertp commented Jan 22, 2025

Now, Excel_Spec's segfaults are preceded by either

org.apache.poi.poifs.filesystem.NotOLE2FileException: Invalid header signature; read 0x6C61657220746F6E, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document
	at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:149)
	at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:115)
	at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:270)
	at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:183)
	at org.enso.table.excel.ExcelConnectionPool.openWorkbook(ExcelConnectionPool.java:309)
	at org.enso.table.excel.ExcelConnectionPool$ConnectionRecord.reopen(ExcelConnectionPool.java:278)
	at org.enso.table.excel.ExcelConnectionPool.openReadOnlyConnection(ExcelConnectionPool.java:72)
	at [email protected]/java.lang.reflect.Method.invoke(Method.java:580)

or

org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)
	at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:128)
	at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:115)
	at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:270)
	at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:183)
	at org.enso.table.excel.ExcelConnectionPool.openWorkbook(ExcelConnectionPool.java:309)
	at org.enso.table.excel.ExcelConnectionPool$ConnectionRecord.reopen(ExcelConnectionPool.java:278)
	at org.enso.table.excel.ExcelConnectionPool.openReadOnlyConnection(ExcelConnectionPool.java:72)
	at org.enso.table.read.ExcelReader.withWorkbook(ExcelReader.java:266)
	at org.enso.table.read.ExcelReader.readRangeByName(ExcelReader.java:181)
	at [email protected]/java.lang.reflect.Method.invoke(Method.java:580)

. randomly. Which feels like this is still related to some configuration.

@hubertp hubertp added the CI: No changelog needed Do not require a changelog entry for this PR. label Jan 22, 2025
@hubertp
Copy link
Collaborator Author

hubertp commented Jan 22, 2025

Further narrowed it down to Excel .xls. .xlsx seems fine.

Apparently `poi` requires `java.awt` and it was segfaulting in a
mysterious way when it was missing.
@hubertp
Copy link
Collaborator Author

hubertp commented Jan 22, 2025

Here was a hint:

Stacktrace for the failing thread 0x00005db97911f2c0 (A=AOT compiled, J=JIT compiled, D=deoptimized, i=inlined):
  A  SP 0x00007ffdbdf141c0 IP 0x00005db960fa710e size=80    [image code] com.oracle.svm.core.code.IsolateEnterStub.JNIFunctions_FatalError_2d6e7de51007501356372d87ae0cc671dc9d1a91(IsolateEnterStub.java:0)
  i  SP 0x00007ffdbdf15270 IP 0x00005db961062904 size=80    [image code] com.oracle.svm.core.jni.JNIOnLoadFunctionPointer.invoke(JNILibraryInitializer.java)
  A  SP 0x00007ffdbdf15270 IP 0x00005db961062904 size=80    [image code] com.oracle.svm.core.jni.JNILibraryInitializer.callOnLoadFunction(JNILibraryInitializer.java:71)
  A  SP 0x00007ffdbdf152c0 IP 0x00005db9610635cc size=32    [image code] com.oracle.svm.core.jni.JNILibraryInitializer.initialize(JNILibraryInitializer.java:132)
  A  SP 0x00007ffdbdf152e0 IP 0x00005db961039d55 size=160   [image code] com.oracle.svm.core.jdk.NativeLibrarySupport.addLibrary(NativeLibrarySupport.java:204)
  A  SP 0x00007ffdbdf15380 IP 0x00005db96103a7a3 size=48    [image code] com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibrary0(NativeLibrarySupport.java:160)
  A  SP 0x00007ffdbdf153b0 IP 0x00005db96103b125 size=176   [image code] com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:123)
  i  SP 0x00007ffdbdf15460 IP 0x00005db9626f156f size=16    [image code] java.lang.ClassLoader.loadLibrary(ClassLoader.java:106)
  i  SP 0x00007ffdbdf15460 IP 0x00005db9626f156f size=16    [image code] java.lang.Runtime.loadLibrary0(Runtime.java:916)
  i  SP 0x00007ffdbdf15460 IP 0x00005db9626f156f size=16    [image code] java.lang.System.loadLibrary(System.java:2063)
  i  SP 0x00007ffdbdf15460 IP 0x00005db9626f156f size=16    [image code] java.awt.Toolkit$2.run(Toolkit.java:1384)
  A  SP 0x00007ffdbdf15460 IP 0x00005db9626f156f size=16    [image code] java.awt.Toolkit$2.run(Toolkit.java:1382)
  A  SP 0x00007ffdbdf15470 IP 0x00005db962af378a size=64    [image code] java.security.AccessController.executePrivileged(AccessController.java:129)
  i  SP 0x00007ffdbdf154b0 IP 0x00005db9626f4cdd size=16    [image code] java.security.AccessController.doPrivileged(AccessController.java:319)
  A  SP 0x00007ffdbdf154b0 IP 0x00005db9626f4cdd size=16    [image code] java.awt.Toolkit.loadLibraries(Toolkit.java:1381)
  A  SP 0x00007ffdbdf154c0 IP 0x00005db9626f41f0 size=32    [image code] java.awt.Toolkit.initStatic(Toolkit.java:1419)
  A  SP 0x00007ffdbdf154e0 IP 0x00005db9626f18a8 size=16    [image code] java.awt.Toolkit.<clinit>(Toolkit.java:1393)
  A  SP 0x00007ffdbdf154f0 IP 0x00005db960eabb6e size=16    [image code] com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:407)
  A  SP 0x00007ffdbdf15500 IP 0x00005db960ea9d7d size=80    [image code] com.oracle.svm.core.classinitialization.ClassInitializationInfo.doInitialize(ClassInitializationInfo.java:323)
  A  SP 0x00007ffdbdf15550 IP 0x00005db960eaa6f5 size=1296  [image code] com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:272)
  A  SP 0x00007ffdbdf15a60 IP 0x00005db9626da9ad size=144   [image code] java.awt.Color.<clinit>(Color.java:277)
  A  SP 0x00007ffdbdf15af0 IP 0x00005db960eabb6e size=16    [image code] com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:407)
  A  SP 0x00007ffdbdf15b00 IP 0x00005db960ea9d7d size=80    [image code] com.oracle.svm.core.classinitialization.ClassInitializationInfo.doInitialize(ClassInitializationInfo.java:323)
  A  SP 0x00007ffdbdf15b50 IP 0x00005db960eaa6f5 size=1296  [image code] com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:272)
  i  SP 0x00007ffdbdf16060 IP 0x00005db963852335 size=1216  [image code] org.apache.poi.hssf.util.HSSFColor$HSSFColorPredefined.<init>(HSSFColor.java:113)
  A  SP 0x00007ffdbdf16060 IP 0x00005db963852335 size=1216  [image code] org.apache.poi.hssf.util.HSSFColor$HSSFColorPredefined.<clinit>(HSSFColor.java:55

Spoiler alert, poi requires AWT 🤦

@hubertp
Copy link
Collaborator Author

hubertp commented Jan 22, 2025

And we may have some issues with awt on MacOS, as per oracle/graal#4124

@@ -188,7 +188,8 @@ add_specs suite_builder =

(table.at "enso_dates" == table.at "py_dates").to_vector . should_equal [True, True]

group_builder.specify "should work with polyglot values coming from JS" <|
pending_js_missing = if Polyglot.is_language_installed "js" then Nothing else "Can't run JavaScript tests, language `js` is not installed."
group_builder.specify "should work with polyglot values coming from JS" pending=pending_js_missing <|
Copy link
Member

Choose a reason for hiding this comment

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

I see. JavaScript is no longer in the bin/enso and thus these tests have to be pending.

@JaroslavTulach
Copy link
Member

JaroslavTulach commented Jan 23, 2025

And we may have some issues with awt on MacOS, as per oracle/graal#4124

Yes we may not be the only ones trying to avoid dependency on AWT:

java.lang.ClassLoader.loadLibrary(ClassLoader.java:106)
  i  SP 0x00007ffdbdf15460 IP 0x00005db9626f156f size=16    [image code] java.lang.Runtime.loadLibrary0(Runtime.java:916)
  i  SP 0x00007ffdbdf15460 IP 0x00005db9626f156f size=16    [image code] java.lang.System.loadLibrary(System.java:2063)
  i  SP 0x00007ffdbdf15460 IP 0x00005db9626f156f size=16    [image code] java.awt.Toolkit$2.run(Toolkit.java:1384)
  A  SP 0x00007ffdbdf15460 IP 0x00005db9626f156f size=16    [image code] java.awt.Toolkit$2.run(Toolkit.java:1382)
  A  SP 0x00007ffdbdf15470 IP 0x00005db962af378a size=64    [image code] 
  A  SP 0x00007ffdbdf154e0 IP 0x00005db9626f18a8 size=16    [image code] java.awt.Toolkit.<clinit>(Toolkit.java:1393)
  i  SP 0x00007ffdbdf16060 IP 0x00005db963852335 size=1216  [image code] org.apache.poi.hssf.util.HSSFColor$HSSFColorPredefined.<init>(HSSFColor.java:113)
  A  SP 0x00007ffdbdf16060 IP 0x00005db963852335 size=1216  [image code] org.apache.poi.hssf.util.HSSFColor$HSSFColorPredefined.<clinit>(HSSFColor.java:55

Spoiler alert, poi requires AWT 🤦

Another possible Quarkiverse goodies:

Btw. there seems to be some fancy Quarkus build system.

@JaroslavTulach
Copy link
Member

I've merged this branch with develop:

Merge: a40c4d2bde a1e01fcc51

and executed:

enso$ ./built-distribution/enso-engine-0.0.0-dev-linux-amd64/enso-0.0.0-dev/bin/enso --run test/Table_Tests
...
5045 tests succeeded.
1 tests failed.
129 tests skipped.
36 groups skipped.
Failed tests: 'should.clear.cache.on.simulated.reload'

that's good, isn't it?

@hubertp
Copy link
Collaborator Author

hubertp commented Jan 23, 2025

that's good, isn't it?

Yes, I resolved all issues yesterday, it seems. Just testing now.

@hubertp
Copy link
Collaborator Author

hubertp commented Jan 23, 2025

Interesting. Now I'm not surprised I had so many issues with it.

GitHub
Apache POI is an API to access Microsoft Office files. This extension provides integration with Apache POI - quarkiverse/quarkus-poi

@hubertp hubertp marked this pull request as ready for review January 23, 2025 12:20
@hubertp hubertp requested a review from Akirathan as a code owner January 23, 2025 12:20
@hubertp
Copy link
Collaborator Author

hubertp commented Jan 23, 2025

Re quarkus-poi - since this configuration now works, I don't see much pressure to switch. But we could consider it later.

Copy link
Member

@jdunkerley jdunkerley left a comment

Choose a reason for hiding this comment

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

Approving from libs side.

@JaroslavTulach
Copy link
Member

Re quarkus-poi - since this configuration now works, I don't see much pressure to switch. But we could consider it later.

The added dependency on java.desktop would be my biggest motivation to switch. But yes, it can be done later.

Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

  • great you got it working
  • I don't like the new dependency on java.desktop
  • it its a shame for server side software to depend on AWT...
  • but let's merge while it work and worry about architecture purity later

@@ -3718,7 +3720,7 @@ lazy val `engine-runner` = project
val NI_MODULES =
"org.graalvm.nativeimage,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.base,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto,com.oracle.graal.graal_enterprise,com.oracle.svm.svm_enterprise"
val JDK_MODULES =
"jdk.localedata,jdk.httpserver,java.naming,java.net.http"
"jdk.localedata,jdk.httpserver,java.naming,java.net.http,java.desktop"
Copy link
Member

Choose a reason for hiding this comment

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

Including java.desktop is undesirable. What can we do to remove it?

  • Use quarkus version?
  • Replace java.awt.Color usage with a substitution?
  • Report a bug for later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would prefer the last option. Configuration is rather fragile and it is easier to improve it incrementally than push it in one go.

Copy link
Member

Choose a reason for hiding this comment

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

Go on, get this in. Otherwise we need to deal #12073 (comment) forever. Once this change is in, we can polish it more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

quarkus-poi doesn't work out-of-the-box. It seems it relies on the fact that one builds it for redhat base image:
https://github.com/quarkiverse/quarkus-poi?tab=readme-ov-file#docker

"name":"org.enso.table.parsing.IdentityParser"
},
{
"name":"org.enso.table.parsing.NumberParser"
Copy link
Member

Choose a reason for hiding this comment

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

Good. languageserver shouldn't care about std-table classes.

"name": "org.enso.base.time.FormatterKind"
},
{
"name": "org.enso.base.time.Time_Of_Day_Utils"
Copy link
Member

Choose a reason for hiding this comment

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

Classes from org.enso.base package belong to std-base. Good.

]
},
{
"name": "org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.WorksheetDocumentImpl",
Copy link
Member

Choose a reason for hiding this comment

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

This is pretty log file!

@JaroslavTulach
Copy link
Member

  • please add the test/Table_Tests to the CI run. Right now it has to be done manually here:

.args(["--run", repo_root.test.join("Base_Tests").as_str()])

@hubertp hubertp added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Jan 24, 2025
@hubertp
Copy link
Collaborator Author

hubertp commented Jan 24, 2025

It appears to fail now with some weird errors that I can't reproduce locally:

2025-01-24T12:38:11.4550135Z  INFO ide_ci::program::command: enso ℹ️     - [PENDING] date_diff and date_add should work correctly with DST
2025-01-24T12:38:11.4550795Z  INFO ide_ci::program::command: enso ℹ️         Reason: May be failing on some Database configurations. ToDo: investigate - https://github.com/enso-org/enso/issues/7326
2025-01-24T12:38:14.9047076Z  INFO ide_ci::program::command: enso ℹ️ [In-Memory] Table.filter: [28/28, 1004ms]
2025-01-24T12:38:14.9049598Z  INFO ide_ci::program::command: enso ℹ️     - [PENDING] text operations should support Unicode normalization (like)
2025-01-24T12:38:14.9050446Z  INFO ide_ci::program::command: enso ℹ️         Reason: There is a bug with Java Regex in Unicode normalized mode (CANON_EQ) with quoting.
2025-01-24T12:38:14.9051254Z  INFO ide_ci::program::command: enso ℹ️ https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8032926
2025-01-24T12:38:15.3297855Z  INFO ide_ci::program::command: enso ℹ️ [WARN] [2025-01-24T13:38:15+01:00] [org.apache.poi.POIDocument] DocumentSummaryInformation property set came back as null
2025-01-24T12:38:15.3298559Z  INFO ide_ci::program::command: enso ℹ️ [WARN] [2025-01-24T13:38:15+01:00] [org.apache.poi.POIDocument] SummaryInformation property set came back as null
2025-01-24T12:38:15.5885932Z  INFO ide_ci::program::command: enso ⚠️ AAAo
2025-01-24T12:38:15.5886969Z  INFO ide_ci::program::command: enso ℹ️ AAAo
2025-01-24T12:38:15.5887411Z  INFO ide_ci::program::command: enso ⚠️ java.lang.Exception
2025-01-24T12:38:15.5888098Z  INFO ide_ci::program::command: enso ⚠️ 	at org.enso.table.excel.ExcelConnectionPool.release(ExcelConnectionPool.java:206)
2025-01-24T12:38:15.5888945Z  INFO ide_ci::program::command: enso ⚠️ 	at org.enso.table.excel.ReadOnlyExcelConnection.close(ReadOnlyExcelConnection.java:26)
2025-01-24T12:38:15.5889745Z  INFO ide_ci::program::command: enso ⚠️ 	at [email protected]/java.lang.reflect.Method.invoke(Method.java:580)
2025-01-24T12:38:15.5890741Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.HostMethodDesc$SingleMethod$MethodReflectImpl.reflectInvoke(HostMethodDesc.java:305)
2025-01-24T12:38:15.5891880Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.HostMethodDesc$SingleMethod$MethodReflectImpl.invoke(HostMethodDesc.java:290)
2025-01-24T12:38:15.5893080Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.GuestToHostCodeCache$GuestToHostInvokeReflect.executeImpl(GuestToHostCodeCache.java:110)
2025-01-24T12:38:15.5894387Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.GuestToHostRootNode.execute(GuestToHostRootNode.java:80)
2025-01-24T12:38:15.5895422Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:745)
2025-01-24T12:38:15.5896623Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callInlined(OptimizedCallTarget.java:550)
2025-01-24T12:38:15.5897945Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedRuntimeSupport.callInlined(OptimizedRuntimeSupport.java:250)
2025-01-24T12:38:15.5898967Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.GuestToHostRootNode.guestToHostCall(GuestToHostRootNode.java:102)
2025-01-24T12:38:15.5900169Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.HostMethodDesc$SingleMethod$ReflectBase.invokeGuestToHost(HostMethodDesc.java:259)
2025-01-24T12:38:15.5901152Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.HostExecuteNode.doInvoke(HostExecuteNode.java:877)
2025-01-24T12:38:15.5902017Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.HostExecuteNode.doFixed(HostExecuteNode.java:140)
2025-01-24T12:38:15.5902975Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.HostExecuteNodeGen$Inlined.executeAndSpecialize(HostExecuteNodeGen.java:403)
2025-01-24T12:38:15.5904011Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.HostExecuteNodeGen$Inlined.execute(HostExecuteNodeGen.java:363)
2025-01-24T12:38:15.5904988Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.HostObject.invokeMember(HostObject.java:465)
2025-01-24T12:38:15.5905986Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.HostObjectGen$InteropLibraryExports$Cached.invokeMemberNode_AndSpecialize(HostObjectGen.java:7156)
2025-01-24T12:38:15.5907143Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.host.HostObjectGen$InteropLibraryExports$Cached.invokeMember(HostObjectGen.java:7142)
2025-01-24T12:38:15.5908746Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.api.interop.InteropLibrary$Asserts.invokeMember(InteropLibrary.java:3595)
2025-01-24T12:38:15.5909800Z  INFO ide_ci::program::command: enso ⚠️ 	at org.graalvm.truffle/com.oracle.truffle.api.interop.InteropLibraryGen$CachedDispatch.invokeMember(InteropLibraryGen.java:8549)
2025-01-24T12:38:15.5910907Z  INFO ide_ci::program::command: enso ⚠️ 	at org.enso.interpreter.node.callable.resolver.HostMethodCallNode.resolveHostMethod(HostMethodCallNode.java:223)
2025-01-24T12:38:15.5912286Z  INFO ide_ci::program::command: enso ⚠️ 	at org.enso.interpreter.node.callable.resolver.HostMethodCallNodeGen.executeAndSpecialize(HostMethodCallNodeGen.java:157)
2025-01-24T12:38:15.5913435Z  INFO ide_ci::program::command: enso ⚠️ 	at org.enso.interpreter.node.callable.resolver.HostMethodCallNodeGen.execute(HostMethodCallNodeGen.java:119)
2025-01-24T12:38:15.5914437Z  INFO ide_ci::program::command: enso ⚠️ 	at org.enso.interpreter.node.callable.InvokeMethodNode.doPolyglot(InvokeMethodNode.java:546)
2025-01-24T12:38:15.5915467Z  INFO ide_ci::program::command: enso ⚠️ 	at org.enso.interpreter.node.callable.InvokeMethodNodeGen.executeAndSpecialize(InvokeMethodNodeGen.java:878)
2025-01-24T12:38:15.5916470Z  INFO ide_ci::program::command: enso ⚠️ 	at org.enso.interpreter.node.callable.InvokeMethodNodeGen.execute(InvokeMethodNodeGen.java:535)
2025-01-24T12:38:15.5917413Z  INFO ide_ci::program::command: enso ⚠️ 	at org.enso.interpreter.node.callable.InvokeCallableNode.invokeDynamicSymbol(InvokeCallableNode.java:276)

CI fails with a useless `java.lang.Exception` which is not reproducible
locally. Attempting to blindly add a few methods/fields, hoping that it
will fix it.
@radeusgd
Copy link
Member

It appears to fail now with some weird errors that I can't reproduce locally:

I think the huge stack trace you see is not an error, it is just a log message that was leftover. This is getting fixed in #12139.

@hubertp
Copy link
Collaborator Author

hubertp commented Jan 24, 2025

It appears to fail now with some weird errors that I can't reproduce locally:

I think the huge stack trace you see is not an error, it is just a log message that was leftover. This is getting fixed in #12139.

You are probably right, yes. The stacktraces were so common and so big that it hid issues with non-Linux OS.

@hubertp
Copy link
Collaborator Author

hubertp commented Jan 24, 2025

And, as suspected, I'm hitting the awt problem on MacOS.

java.awt support on MacOS is still missing therefore
bundling/configuring resources for it only makes sense on Linux/Windows.
That was unsatisafactory.

This change uses native image's substitution mechanism to avoid any awt
library loading. The latter will not be functional when one attempts to
use it but our implementation does not rely on it at all.
@hubertp
Copy link
Collaborator Author

hubertp commented Jan 26, 2025

I used substitution after all because of lack of support for awt on MacOS - our builds were failing.This is acceptable as our implementation does not rely on that part at all.

Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

Shouldn't you also remove dependency on java.desktop module?

@TargetClass(java.awt.GraphicsEnvironment.class)
final class ReplacementGraphicsEnvironment {
@Substitute
public static boolean isHeadless() { return true; }
Copy link
Member

Choose a reason for hiding this comment

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

Yup, this one is straightforward.

import com.oracle.svm.core.annotate.Substitute;

@TargetClass(java.awt.Toolkit.class)
final class ReplacementToolkit {
Copy link
Member

Choose a reason for hiding this comment

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

Is that all to get rid of dependency on AWT?

Copy link
Collaborator Author

@hubertp hubertp Jan 26, 2025

Choose a reason for hiding this comment

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

For our use-cases, yes. Note that this renders AWT pretty much useless but that's OK. I suspect NI eliminates most if not all java.desktop code. java.beans (in DataFormatter) still requires java.desktop and I couldn't get rid of that dependency the same way; this time because of log4j 🤦 .

@hubertp
Copy link
Collaborator Author

hubertp commented Jan 26, 2025

Shouldn't you also remove dependency on java.desktop module?

No. It needs it to perform the substitution at build-time, sadly.

@hubertp hubertp merged commit a64dd4a into develop Jan 26, 2025
48 of 49 checks passed
@hubertp hubertp deleted the wip/hubert/12006-table-tests-ni branch January 26, 2025 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run test/Table_Tests in native image mode
4 participants