-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1226 from astrelsky/utfpath
handle non ascii classpath with system classloader
- Loading branch information
Showing
14 changed files
with
272 additions
and
29 deletions.
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); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 @@ | ||
Test to verify that service providers are found and used when placed in a non ascii 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,20 @@ | ||
apply plugin: 'java' | ||
apply plugin: 'eclipse' | ||
|
||
sourceCompatibility = 8 | ||
targetCompatibility = 8 | ||
|
||
|
||
tasks.withType(JavaCompile) { | ||
options.release = 8 | ||
options.debug = false | ||
} | ||
|
||
jar { | ||
destinationDirectory = file('dist') | ||
from ('./src/main/java') { | ||
include 'META-INF/services/java.time.zone.ZoneRulesProvider' | ||
} | ||
} | ||
|
||
build.dependsOn(jar) |
28 changes: 28 additions & 0 deletions
28
project/jars/unicode_à😎/service/src/main/java/org/jpype/service/JpypeZoneRulesProvider.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,28 @@ | ||
package org.jpype.service; | ||
|
||
import java.time.ZoneId; | ||
import java.time.zone.ZoneRules; | ||
import java.time.zone.ZoneRulesProvider; | ||
import java.util.Collections; | ||
import java.util.NavigableMap; | ||
import java.util.Set; | ||
import java.util.TreeMap; | ||
|
||
public class JpypeZoneRulesProvider extends ZoneRulesProvider { | ||
|
||
@Override | ||
protected Set<String> provideZoneIds() { | ||
return Collections.singleton("JpypeTest/Timezone"); | ||
} | ||
|
||
@Override | ||
protected ZoneRules provideRules(String zoneId, boolean forCaching) { | ||
return ZoneId.of("UTC").getRules(); | ||
} | ||
|
||
@Override | ||
protected NavigableMap<String, ZoneRules> provideVersions(String zoneId) { | ||
return new TreeMap<>(); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
.../unicode_à😎/service/src/main/resources/META-INF/services/java.time.zone.ZoneRulesProvider
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 @@ | ||
org.jpype.service.JpypeZoneRulesProvider |
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); | ||
} | ||
} |
Binary file not shown.
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