From 862e9b846f769be65ea6991abd652a2a29dec412 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 14 May 2020 16:59:21 +0300 Subject: [PATCH] Exclude all classes from underlying JDK --- .../main/resources/META-INF/teavm.properties | 1 + .../parsing/ClasspathResourceMapper.java | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/classlib/src/main/resources/META-INF/teavm.properties b/classlib/src/main/resources/META-INF/teavm.properties index dbf34ff21..916859c71 100644 --- a/classlib/src/main/resources/META-INF/teavm.properties +++ b/classlib/src/main/resources/META-INF/teavm.properties @@ -11,5 +11,6 @@ # 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. +includePackageHierarchy|java=false stripPrefixFromPackageHierarchyClasses|org.teavm.classlib.java=T mapPackageHierarchy|org.teavm.classlib.java=java \ No newline at end of file diff --git a/core/src/main/java/org/teavm/parsing/ClasspathResourceMapper.java b/core/src/main/java/org/teavm/parsing/ClasspathResourceMapper.java index 7ce742a8a..c29844f6e 100644 --- a/core/src/main/java/org/teavm/parsing/ClasspathResourceMapper.java +++ b/core/src/main/java/org/teavm/parsing/ClasspathResourceMapper.java @@ -127,7 +127,9 @@ public class ClasspathResourceMapper implements Function, C } } if (cls == null) { - cls = innerMapper.apply(name); + if (!classExclusions.apply(name)) { + cls = innerMapper.apply(name); + } } if (cls != null && !elementFilters.isEmpty()) { for (ElementFilter filter : elementFilters) { @@ -212,40 +214,41 @@ public class ClasspathResourceMapper implements Function, C case STRIP_PREFIX_FROM_PACKAGE_HIERARCHY_PREFIX: prefixMapping.setPackageHierarchyClassPrefixRule(instruction[1].split("\\."), properties.getProperty(propertyName)); - continue; + break; case STRIP_PREFIX_FROM_PACKAGE_PREFIX: prefixMapping.setPackageClassPrefixRule(instruction[1].split("\\."), properties.getProperty(propertyName)); - continue; + break; case MAP_PACKAGE_HIERARCHY_PREFIX: packageMappings.addPackageHierarchyMappingRule(properties.getProperty(propertyName).split("\\."), instruction[1]); reversePackageMappings.addPackageHierarchyMappingRule(instruction[1].split("\\."), properties.getProperty(propertyName)); - continue; + break; case MAP_PACKAGE_PREFIX: packageMappings .addPackageMappingRule(properties.getProperty(propertyName).split("\\."), instruction[1]); reversePackageMappings .addPackageMappingRule(instruction[1].split("\\."), properties.getProperty(propertyName)); - continue; + break; case MAP_CLASS_PREFIX: classMappings .addClassMappingRule(properties.getProperty(propertyName).split("\\."), instruction[1]); reverseClassMappings .addClassMappingRule(instruction[1].split("\\."), properties.getProperty(propertyName)); - continue; + break; case INCLUDE_PACKAGE_HIERARCHY_PREFIX: classExclusions.setPackageHierarchyExclusion(instruction[1].split("\\."), !Boolean.parseBoolean(properties.getProperty(propertyName))); - continue; + break; case INCLUDE_PACKAGE_PREFIX: classExclusions.setPackageExclusion(instruction[1].split("\\."), !Boolean.parseBoolean(properties.getProperty(propertyName))); - continue; + break; case INCLUDE_CLASS_PREFIX: classExclusions.setClassExclusion(instruction[1].split("\\."), !Boolean.parseBoolean(properties.getProperty(propertyName))); + break; } } }