-
Notifications
You must be signed in to change notification settings - Fork 334
Using Channel to load Java classes
#13238
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
Merged
Merged
Changes from all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
53b2490
Separating JVM functionality into own jvm-channel project
JaroslavTulach f0cff3d
Unit test using Channel functionality in a single JVM
JaroslavTulach 365d50d
Testing ChannelInSingleJvm in jvm-channel project itself
JaroslavTulach 837877d
jvm-interop module with dependency on Truffle
JaroslavTulach 701006e
The enso language may not be enabled
JaroslavTulach 9817a8e
Using Object[] as class argument yield proper AP error
JaroslavTulach 9c129de
Messages to find out if an object is an array
JaroslavTulach 2452421
Access String array elements
JaroslavTulach b96c9ff
Transfer all primitive types
JaroslavTulach dd9287c
Invoke methods on the other objects
JaroslavTulach 73f087b
Able to invoke BigDecimal.add(BigDecimal) in the other JVM
JaroslavTulach 3ed9c4a
Transfer of any TruffleObject yields OtherJvmObject and backwards
JaroslavTulach 7a4024d
Report duplicated registrations
JaroslavTulach 44edc03
Invoke java.lang.Short.valueOf in the other JVM
JaroslavTulach 0b8c477
loadClass yields an exception
JaroslavTulach ba92d27
LoadClass really throws ClassNotFoundException
JaroslavTulach cd2e6b4
Merge remote-tracking branch 'origin/develop' into wip/jtulach/Channe…
JaroslavTulach cec892c
Provide support for additional PolyglotSymbolResolver extensions
JaroslavTulach cf3309c
Environment is associated with every DistributionManager
JaroslavTulach 2b58d27
Sending messages must be behind @TruffleBoundary
JaroslavTulach e41d046
Use OtherSymbolResolver (via PolyglotSymbolResolver API) to load Java…
JaroslavTulach d6960ec
debug log message when setting value of java.home property
JaroslavTulach 31eff03
Using Context with HostAccess.ALL
JaroslavTulach fc8f92e
Removing debugging printf statatements
JaroslavTulach 1018884
Renaming to use OtherJvm prefix
JaroslavTulach 9e75dd5
Environment is associated with DistributionManager
JaroslavTulach 14d78f0
Easier to support execute message
JaroslavTulach 2bf6895
Enter and leave the context before sending a message
JaroslavTulach 3c81a1e
Delegate to default library implementation for non-InteropLibrary mes…
JaroslavTulach bb92781
Even mock Channel has two connected instances
JaroslavTulach 0b970a2
Giving Channel.getData() to store local info on both JVM sides
JaroslavTulach 3c7b2a6
Making os-environment/test pass again
JaroslavTulach f76710d
Fixing typo
JaroslavTulach 673b8c0
Add entries to classpath
JaroslavTulach dda69c8
org.enso.jvm.interop needs a reflective registration to construct its…
JaroslavTulach 139914d
Associate readResolve and writeReplace with Pool
JaroslavTulach 4cb9c11
Merge remote-tracking branch 'origin/develop' into wip/jtulach/Channe…
JaroslavTulach 0af6689
DistributionManager is already associated with an environment
JaroslavTulach 7dabb52
Putting the configuration of a Channel into a dedicated Config
JaroslavTulach d8d7493
Reverting back to develop version
JaroslavTulach 82c431e
Using createPool(Channel) to avoid global state in OtherJvmPool
JaroslavTulach b5c973f
Map of objects shall not be global
JaroslavTulach 73a8916
withWriteReplace and withReadResolve instance methods form a nicer API
JaroslavTulach f383a7d
These options cannot be passed to in process JVM - removing
JaroslavTulach c47eefe
Testing differences in propagation of exceptions
JaroslavTulach 269d66e
Support for --vm.D=polyglot.enso.hostClassLoading=false experimental …
JaroslavTulach f6171fb
Propagating UnsupportedMessageException
JaroslavTulach bd95d18
Compatible identity checks
JaroslavTulach 6b77ae7
Can callback with a String
JaroslavTulach 5d6adb2
Channel.isMaster
JaroslavTulach e745a10
Only enter the TruffleClassLoader.ctx() when on slave
JaroslavTulach 4f373cd
Encapsulate general problems with other JVM into Truffle exception
JaroslavTulach 44efcf3
Merge remote-tracking branch 'origin/develop' into wip/jtulach/Channe…
JaroslavTulach fdc89fb
Opt-in via --vm.D=polyglot.enso.classLoading to enable other JVM clas…
JaroslavTulach dc4db1f
Initialize with null
JaroslavTulach 6018f38
Removing non-javadoc documentation
JaroslavTulach 9ea85e3
Removing commented out requires statements
JaroslavTulach 22f170c
A javadoc
JaroslavTulach e765579
Using name constants to identify special isolates
JaroslavTulach cda3980
Associate Channel.isMaster with a Context when running OtherJvmObject…
JaroslavTulach 66a2045
Avoid PolyglotSymbolResolver.addToClassPath until it is turned on
JaroslavTulach 06d01e5
Merge remote-tracking branch 'origin/develop' into wip/jtulach/Channe…
JaroslavTulach f4b374e
windows-2019 image is being deprecated
JaroslavTulach d77b80b
Backout of f383a7dfc412265597979ef245ba5b60fce0369d
JaroslavTulach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
engine/common/src/main/java/org/enso/common/PolyglotSymbolResolver.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package org.enso.common; | ||
|
|
||
| import java.net.URL; | ||
| import java.util.ArrayList; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.ServiceLoader; | ||
|
|
||
| /** | ||
| * Generic support for loading Java polyglot symbols. The resolver provides two kinds of interfaces: | ||
| * | ||
| * <ul> | ||
| * <li>the client API - represented by all the <b>public static</b> methods | ||
| * <li>the SPI - e.g. service provider interface - those are the <b>protected abstract</b> methods | ||
| * </ul> | ||
| * | ||
| * Those who tend to extend the capabilities of loading Java classes into Enso runtime shall | ||
| * register their own implementation visible via {@link ServiceLoader}. | ||
| * | ||
| * @see RuntimeOptions#HOST_CLASS_LOADING | ||
| */ | ||
| public abstract class PolyglotSymbolResolver { | ||
| private static final Collection<PolyglotSymbolResolver> ALL; | ||
|
|
||
| static { | ||
| var arr = new ArrayList<PolyglotSymbolResolver>(); | ||
| for (var l : ServiceLoader.load(PolyglotSymbolResolver.class)) { | ||
| arr.add(l); | ||
| } | ||
| ALL = Collections.unmodifiableList(arr); | ||
| } | ||
|
|
||
| /** | ||
| * Search all providers for given name. | ||
| * | ||
| * @param name dot separated name to search for | ||
| * @return non-null object representing the name | ||
| * @throws java.lang.ClassNotFoundException if no name was found | ||
| */ | ||
| public static Object loadClass(String name) throws ClassNotFoundException { | ||
| ClassNotFoundException ex = null; | ||
| for (var p : ALL) { | ||
| try { | ||
| var found = p.handleLoadClass(name); | ||
| assert found != null; | ||
| return found; | ||
| } catch (ClassNotFoundException cnfe) { | ||
| ex = cnfe; | ||
| } | ||
| } | ||
| if (ex == null) { | ||
| throw new ClassNotFoundException(name); | ||
| } else { | ||
| throw ex; | ||
| } | ||
| } | ||
|
|
||
| public static void addToClassPath(URL url) { | ||
| for (var p : ALL) { | ||
| p.handleAddToClassPath(url); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Subclasses implement this method to search for class with the provided name. | ||
| * | ||
| * @param name dot separated name to search for | ||
| * @return non-{@code null} object representing the name | ||
| * @throws java.lang.ClassNotFoundException if no name was found | ||
| */ | ||
| protected abstract Object handleLoadClass(String name) throws ClassNotFoundException; | ||
|
|
||
| protected abstract void handleAddToClassPath(URL url); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,8 +35,8 @@ | |
| import org.enso.distribution.DistributionManager; | ||
| import org.enso.distribution.Environment; | ||
| import org.enso.editions.DefaultEdition; | ||
| import org.enso.jvm.channel.JVM; | ||
| import org.enso.libraryupload.LibraryUploader.UploadFailedError; | ||
| import org.enso.os.environment.jni.JVM; | ||
| import org.enso.pkg.Contact; | ||
| import org.enso.pkg.PackageManager; | ||
| import org.enso.pkg.PackageManager$; | ||
|
|
@@ -1574,6 +1574,15 @@ private void launch(String[] args) throws IOException, InterruptedException, URI | |
| } | ||
| } | ||
|
|
||
| if (System.getProperty("java.home") == null) { | ||
| assert HostEnsoUtils.isAot() : "Otherwise java.home would be defined"; | ||
| var exe = JavaFinder.findJavaExecutable(); | ||
| if (exe != null) { | ||
| var path = exe.getParentFile().getParentFile().getAbsolutePath(); | ||
JaroslavTulach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| System.setProperty("java.home", path); | ||
| LOGGER.debug("Setting java.home property for AOT mode to {}", path); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| } | ||
| handleLaunch(originalCwdOrNull, line, logLevel, logMasking[0]); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.