-
Notifications
You must be signed in to change notification settings - Fork 183
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
handle non ascii classpath with system classloader #1226
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3a026bf
handle non ascii classpath with system classloader #1194 #1222
astrelsky 4201de6
please stfu mypy
astrelsky 8516121
fixed stupid mistake causing failure when specifying -Djava.class.path
astrelsky 157c4e7
fixed test issue from classpath separator
astrelsky a1b6701
add service test
astrelsky d86aa67
stop crying github bot
astrelsky 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 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
43 changes: 43 additions & 0 deletions
43
native/java/org/jpype/classloader/JpypeSystemClassLoader.java
This file contains 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,43 @@ | ||
/* **************************************************************************** | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
See NOTICE file for details. | ||
**************************************************************************** */ | ||
package org.jpype.classloader; | ||
|
||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
import java.nio.file.Paths; | ||
|
||
public final class JpypeSystemClassLoader extends URLClassLoader { | ||
|
||
public JpypeSystemClassLoader(ClassLoader parent) throws Throwable { | ||
super(new URL[0], parent); | ||
} | ||
|
||
public void addPath(String path) throws Throwable { | ||
addURL(Paths.get(path).toAbsolutePath().toUri().toURL()); | ||
} | ||
|
||
public void addPaths(String[] paths) throws Throwable { | ||
for (String path : paths) { | ||
addPath(path); | ||
} | ||
} | ||
|
||
// this is required to add a Java agent even if it is already in the path | ||
@SuppressWarnings("unused") | ||
private void appendToClassPathForInstrumentation(String path) throws Throwable { | ||
addPath(path); | ||
} | ||
} |
This file contains 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,42 @@ | ||
/* **************************************************************************** | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
See NOTICE file for details. | ||
**************************************************************************** */ | ||
package jpype.startup; | ||
|
||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
import java.nio.file.Paths; | ||
|
||
public class TestSystemClassLoader extends URLClassLoader { | ||
|
||
public TestSystemClassLoader(ClassLoader parent) throws Throwable { | ||
super(new URL[0], parent); | ||
} | ||
|
||
public void addPath(String path) throws Throwable { | ||
addURL(Paths.get(path).toAbsolutePath().toUri().toURL()); | ||
} | ||
|
||
public void addPaths(String[] paths) throws Throwable { | ||
for (String path : paths) { | ||
addPath(path); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unused") // needed to start with agent | ||
private void appendToClassPathForInstrumentation(String path) throws Throwable { | ||
addPath(path); | ||
} | ||
} |
This file contains 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 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we pass the class path as a different variable and then use it. The issue I am concerned about is that of those jars that specify a service.
https://medium.com/@yureshcs/services-and-service-provider-with-java-9-modules-ddd0170749b0
In that past when we did testing is was clear that services were only recognized if they were loaded on the initial class_path. I believe it is the case for certain things like databases. Unfortunately, it was a while since I last looked at the issue so I don't have a working test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are still loaded on the initial classpath (loaded by the system class loader). I can figure out how to put together a service and add a test case for it tomorrow.
Services are loaded and instantiated lazily. So as long as the paths are added to the system classpath before returning from startJVM, before the user can do anything, then we should be ok.