mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Add ability to fine tune transpiler class substitutions.
This commit is contained in:
parent
3254dce53b
commit
e0fc5d834b
|
@ -11,5 +11,5 @@
|
|||
# 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.
|
||||
packagePrefix.java=org.teavm.classlib
|
||||
classPrefix.java=T
|
||||
stripPrefixFromPackageHierarchyClasses|org.teavm.classlib.java=T
|
||||
mapPackageHierarchy|org.teavm.classlib.java=java
|
|
@ -20,53 +20,69 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Function;
|
||||
import org.teavm.common.CachedFunction;
|
||||
import org.teavm.model.ClassHolder;
|
||||
import org.teavm.model.FieldHolder;
|
||||
import org.teavm.model.MethodHolder;
|
||||
import org.teavm.model.ReferenceCache;
|
||||
import org.teavm.parsing.substitution.ClassExclusions;
|
||||
import org.teavm.parsing.substitution.ClassMappings;
|
||||
import org.teavm.parsing.substitution.OrderedProperties;
|
||||
import org.teavm.parsing.substitution.PrefixMapping;
|
||||
import org.teavm.vm.spi.ElementFilter;
|
||||
|
||||
public class ClasspathResourceMapper implements Function<String, ClassHolder>, ClassDateProvider {
|
||||
private static final String PACKAGE_PREFIX = "packagePrefix.";
|
||||
private static final String CLASS_PREFIX = "classPrefix.";
|
||||
private static final String STRIP_PREFIX_FROM_PREFIX = "stripPrefixFrom";
|
||||
private static final String STRIP_PREFIX_FROM_PACKAGE_HIERARCHY_PREFIX =
|
||||
STRIP_PREFIX_FROM_PREFIX + "PackageHierarchyClasses";
|
||||
private static final String STRIP_PREFIX_FROM_PACKAGE_PREFIX = STRIP_PREFIX_FROM_PREFIX + "PackageClasses";
|
||||
private static final String MAP_PREFIX = "map";
|
||||
private static final String MAP_PACKAGE_HIERARCHY_PREFIX = MAP_PREFIX + "PackageHierarchy";
|
||||
private static final String MAP_PACKAGE_PREFIX = MAP_PREFIX + "Package";
|
||||
private static final String MAP_CLASS_PREFIX = MAP_PREFIX + "Class";
|
||||
private static final String INCLUDE_PREFIX = "include";
|
||||
private static final String INCLUDE_PACKAGE_HIERARCHY_PREFIX = INCLUDE_PREFIX + "PackageHierarchy";
|
||||
private static final String INCLUDE_PACKAGE_PREFIX = INCLUDE_PREFIX + "Package";
|
||||
private static final String INCLUDE_CLASS_PREFIX = INCLUDE_PREFIX + "Class";
|
||||
private static final Date VOID_DATE = new Date(0);
|
||||
private Function<String, ClassHolder> innerMapper;
|
||||
private List<Transformation> transformations = new ArrayList<>();
|
||||
private ClassRefsRenamer renamer;
|
||||
private ClassLoader classLoader;
|
||||
private Map<String, ModificationDate> modificationDates = new HashMap<>();
|
||||
private ReferenceCache referenceCache;
|
||||
private Map<String, Date> modificationDates = new HashMap<>();
|
||||
private List<ElementFilter> elementFilters = new ArrayList<>();
|
||||
|
||||
private static class Transformation {
|
||||
String packageName;
|
||||
String packagePrefix = "";
|
||||
String fullPrefix = "";
|
||||
String classPrefix = "";
|
||||
}
|
||||
private ClassMappings classMappings = new ClassMappings();
|
||||
private PrefixMapping prefixMapping = new PrefixMapping();
|
||||
private ClassMappings packageMappings = new ClassMappings();
|
||||
private ClassExclusions classExclusions = new ClassExclusions();
|
||||
private ClassMappings reverseClassMappings = new ClassMappings();
|
||||
private ClassMappings reversePackageMappings = new ClassMappings();
|
||||
|
||||
public ClasspathResourceMapper(ClassLoader classLoader, ReferenceCache referenceCache,
|
||||
Function<String, ClassHolder> provider) {
|
||||
this.innerMapper = provider;
|
||||
this.referenceCache = referenceCache;
|
||||
try {
|
||||
Enumeration<URL> resources = classLoader.getResources("META-INF/teavm.properties");
|
||||
Map<String, Transformation> transformationMap = new HashMap<>();
|
||||
while (resources.hasMoreElements()) {
|
||||
URL resource = resources.nextElement();
|
||||
Properties properties = new Properties();
|
||||
Properties properties = new OrderedProperties();
|
||||
try (InputStream input = resource.openStream()) {
|
||||
properties.load(input);
|
||||
}
|
||||
loadProperties(properties, transformationMap);
|
||||
loadProperties(properties);
|
||||
}
|
||||
transformations.addAll(transformationMap.values());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Error reading resources", e);
|
||||
}
|
||||
renamer = new ClassRefsRenamer(referenceCache, new CachedFunction<>(classNameMapper));
|
||||
renamer = new ClassRefsRenamer(referenceCache, new CachedFunction<>(this::toUnmappedClassName));
|
||||
|
||||
for (ElementFilter elementFilter : ServiceLoader.load(ElementFilter.class)) {
|
||||
elementFilters.add(elementFilter);
|
||||
|
@ -78,61 +94,57 @@ public class ClasspathResourceMapper implements Function<String, ClassHolder>, C
|
|||
public ClasspathResourceMapper(Properties properties, ReferenceCache referenceCache,
|
||||
Function<String, ClassHolder> innerMapper) {
|
||||
this.innerMapper = innerMapper;
|
||||
this.referenceCache = referenceCache;
|
||||
Map<String, Transformation> transformationMap = new HashMap<>();
|
||||
loadProperties(properties, transformationMap);
|
||||
transformations.addAll(transformationMap.values());
|
||||
renamer = new ClassRefsRenamer(referenceCache, new CachedFunction<>(classNameMapper));
|
||||
}
|
||||
|
||||
private void loadProperties(Properties properties, Map<String, Transformation> cache) {
|
||||
for (String propertyName : properties.stringPropertyNames()) {
|
||||
if (propertyName.startsWith(PACKAGE_PREFIX)) {
|
||||
String packageName = propertyName.substring(PACKAGE_PREFIX.length());
|
||||
Transformation transformation = getTransformation(cache, packageName);
|
||||
transformation.packagePrefix = properties.getProperty(propertyName) + ".";
|
||||
transformation.fullPrefix = transformation.packagePrefix + transformation.packageName;
|
||||
} else if (propertyName.startsWith(CLASS_PREFIX)) {
|
||||
String packageName = propertyName.substring(CLASS_PREFIX.length());
|
||||
Transformation transformation = getTransformation(cache, packageName);
|
||||
transformation.classPrefix = properties.getProperty(propertyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Transformation getTransformation(Map<String, Transformation> cache, String packageName) {
|
||||
Transformation transformation = cache.get(packageName);
|
||||
if (transformation == null) {
|
||||
transformation = new Transformation();
|
||||
transformation.packageName = packageName + ".";
|
||||
transformation.fullPrefix = packageName + ".";
|
||||
cache.put(packageName, transformation);
|
||||
}
|
||||
return transformation;
|
||||
loadProperties(properties);
|
||||
renamer = new ClassRefsRenamer(referenceCache, new CachedFunction<>(this::toUnmappedClassName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassHolder apply(String name) {
|
||||
ClassHolder cls = null;
|
||||
for (String mappedClassName : classMappings.apply(name)) {
|
||||
if (classExclusions.apply(mappedClassName)) {
|
||||
continue;
|
||||
}
|
||||
ClassHolder classHolder = innerMapper.apply(mappedClassName);
|
||||
if (classHolder == null) {
|
||||
continue;
|
||||
}
|
||||
cls = renamer.rename(classHolder);
|
||||
break;
|
||||
}
|
||||
if (cls == null) {
|
||||
for (String mappedClassName : packageMappings.apply(name)) {
|
||||
mappedClassName = prefixMapping.apply(mappedClassName);
|
||||
if (classExclusions.apply(mappedClassName)) {
|
||||
continue;
|
||||
}
|
||||
ClassHolder classHolder = innerMapper.apply(mappedClassName);
|
||||
if (classHolder == null) {
|
||||
continue;
|
||||
}
|
||||
cls = renamer.rename(classHolder);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cls == null) {
|
||||
cls = innerMapper.apply(name);
|
||||
}
|
||||
if (cls != null && !elementFilters.isEmpty()) {
|
||||
for (ElementFilter filter : elementFilters) {
|
||||
if (!filter.acceptClass(name)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
ClassHolder cls = find(name);
|
||||
|
||||
if (cls != null) {
|
||||
for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) {
|
||||
MethodHolder[] methodHolders = cls.getMethods().toArray(new MethodHolder[0]);
|
||||
FieldHolder[] fieldHolders = cls.getFields().toArray(new FieldHolder[0]);
|
||||
for (ElementFilter filter : elementFilters) {
|
||||
for (MethodHolder method : methodHolders) {
|
||||
if (!filter.acceptMethod(method.getReference())) {
|
||||
cls.removeMethod(method);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (FieldHolder field : cls.getFields().toArray(new FieldHolder[0])) {
|
||||
for (ElementFilter filter : elementFilters) {
|
||||
for (FieldHolder field : fieldHolders) {
|
||||
if (!filter.acceptField(field.getReference())) {
|
||||
cls.removeField(field);
|
||||
break;
|
||||
|
@ -140,77 +152,31 @@ public class ClasspathResourceMapper implements Function<String, ClassHolder>, C
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cls;
|
||||
}
|
||||
|
||||
private ClassHolder find(String name) {
|
||||
for (Transformation transformation : transformations) {
|
||||
if (name.startsWith(transformation.packageName)) {
|
||||
int index = name.lastIndexOf('.');
|
||||
String className = name.substring(index + 1);
|
||||
String packageName = index > 0 ? name.substring(0, index) : "";
|
||||
ClassHolder classHolder = innerMapper.apply(transformation.packagePrefix + packageName
|
||||
+ "." + transformation.classPrefix + className);
|
||||
if (classHolder != null) {
|
||||
classHolder = renamer.rename(classHolder);
|
||||
}
|
||||
return classHolder;
|
||||
}
|
||||
}
|
||||
return innerMapper.apply(name);
|
||||
}
|
||||
|
||||
private String renameClass(String name) {
|
||||
for (Transformation transformation : transformations) {
|
||||
if (name.startsWith(transformation.fullPrefix)) {
|
||||
int index = name.lastIndexOf('.');
|
||||
String className = name.substring(index + 1);
|
||||
String packageName = name.substring(0, index);
|
||||
if (className.startsWith(transformation.classPrefix)) {
|
||||
String newName = packageName.substring(transformation.packagePrefix.length()) + "."
|
||||
+ className.substring(transformation.classPrefix.length());
|
||||
return referenceCache.getCached(newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private Function<String, String> classNameMapper = this::renameClass;
|
||||
|
||||
@Override
|
||||
public Date getModificationDate(String className) {
|
||||
ModificationDate mdate = modificationDates.get(className);
|
||||
Date mdate = modificationDates.get(className);
|
||||
if (mdate == null) {
|
||||
mdate = new ModificationDate();
|
||||
mdate = getOriginalModificationDate(toUnmappedClassName(className));
|
||||
modificationDates.put(className, mdate);
|
||||
mdate.date = calculateModificationDate(className);
|
||||
}
|
||||
return mdate.date;
|
||||
return mdate == VOID_DATE ? null : mdate;
|
||||
}
|
||||
|
||||
private Date calculateModificationDate(String className) {
|
||||
int dotIndex = className.lastIndexOf('.');
|
||||
String packageName;
|
||||
String simpleName;
|
||||
if (dotIndex > 0) {
|
||||
packageName = className.substring(0, dotIndex + 1);
|
||||
simpleName = className.substring(dotIndex + 1);
|
||||
} else {
|
||||
packageName = "";
|
||||
simpleName = className;
|
||||
private String toUnmappedClassName(String name) {
|
||||
if (classExclusions.apply(name)) {
|
||||
return name;
|
||||
}
|
||||
for (Transformation transformation : transformations) {
|
||||
if (packageName.startsWith(transformation.packageName)) {
|
||||
String fullName = transformation.packagePrefix + packageName + transformation.classPrefix + simpleName;
|
||||
Date date = getOriginalModificationDate(fullName);
|
||||
if (date != null) {
|
||||
return date;
|
||||
name = prefixMapping.revert(name);
|
||||
for (String originalClassName : reverseClassMappings.apply(name)) {
|
||||
return originalClassName;
|
||||
}
|
||||
for (String originalClassName : reversePackageMappings.apply(name)) {
|
||||
return originalClassName;
|
||||
}
|
||||
}
|
||||
return getOriginalModificationDate(className);
|
||||
return name;
|
||||
}
|
||||
|
||||
private Date getOriginalModificationDate(String className) {
|
||||
|
@ -239,7 +205,48 @@ public class ClasspathResourceMapper implements Function<String, ClassHolder>, C
|
|||
}
|
||||
}
|
||||
|
||||
static class ModificationDate {
|
||||
Date date;
|
||||
private void loadProperties(Properties properties) {
|
||||
for (String propertyName : properties.stringPropertyNames()) {
|
||||
final String[] instruction = propertyName.split("\\|", 2);
|
||||
switch (instruction[0]) {
|
||||
case STRIP_PREFIX_FROM_PACKAGE_HIERARCHY_PREFIX:
|
||||
prefixMapping.setPackageHierarchyClassPrefixRule(instruction[1].split("\\."),
|
||||
properties.getProperty(propertyName));
|
||||
continue;
|
||||
case STRIP_PREFIX_FROM_PACKAGE_PREFIX:
|
||||
prefixMapping.setPackageClassPrefixRule(instruction[1].split("\\."),
|
||||
properties.getProperty(propertyName));
|
||||
continue;
|
||||
case MAP_PACKAGE_HIERARCHY_PREFIX:
|
||||
packageMappings.addPackageHierarchyMappingRule(properties.getProperty(propertyName).split("\\."),
|
||||
instruction[1]);
|
||||
reversePackageMappings.addPackageHierarchyMappingRule(instruction[1].split("\\."),
|
||||
properties.getProperty(propertyName));
|
||||
continue;
|
||||
case MAP_PACKAGE_PREFIX:
|
||||
packageMappings
|
||||
.addPackageMappingRule(properties.getProperty(propertyName).split("\\."), instruction[1]);
|
||||
reversePackageMappings
|
||||
.addPackageMappingRule(instruction[1].split("\\."), properties.getProperty(propertyName));
|
||||
continue;
|
||||
case MAP_CLASS_PREFIX:
|
||||
classMappings
|
||||
.addClassMappingRule(properties.getProperty(propertyName).split("\\."), instruction[1]);
|
||||
reverseClassMappings
|
||||
.addClassMappingRule(instruction[1].split("\\."), properties.getProperty(propertyName));
|
||||
continue;
|
||||
case INCLUDE_PACKAGE_HIERARCHY_PREFIX:
|
||||
classExclusions.setPackageHierarchyExclusion(instruction[1].split("\\."),
|
||||
!Boolean.parseBoolean(properties.getProperty(propertyName)));
|
||||
continue;
|
||||
case INCLUDE_PACKAGE_PREFIX:
|
||||
classExclusions.setPackageExclusion(instruction[1].split("\\."),
|
||||
!Boolean.parseBoolean(properties.getProperty(propertyName)));
|
||||
continue;
|
||||
case INCLUDE_CLASS_PREFIX:
|
||||
classExclusions.setClassExclusion(instruction[1].split("\\."),
|
||||
!Boolean.parseBoolean(properties.getProperty(propertyName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ClassExclusions implements Function<String, Boolean> {
|
||||
private final Map<String, Boolean> classExclusions = new HashMap<>();
|
||||
private Boolean isExcluded;
|
||||
private Boolean isSubpackagesExcluded;
|
||||
private final Map<String, ClassExclusions> subExclusions = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Boolean apply(String className) {
|
||||
return isExcluded(className.split("\\.")) == Boolean.TRUE;
|
||||
}
|
||||
|
||||
public void setPackageHierarchyExclusion(String[] packageNameSegments, boolean isExcluded) {
|
||||
if (packageNameSegments == null || packageNameSegments.length < 1) {
|
||||
isSubpackagesExcluded = isExcluded;
|
||||
return;
|
||||
}
|
||||
subExclusions.computeIfAbsent(packageNameSegments[0], packageName -> new ClassExclusions())
|
||||
.setPackageHierarchyExclusion(
|
||||
Arrays.copyOfRange(packageNameSegments, 1, packageNameSegments.length), isExcluded);
|
||||
}
|
||||
|
||||
public void setPackageExclusion(String[] packageNameSegments, boolean isExcluded) {
|
||||
if (packageNameSegments == null || packageNameSegments.length < 1) {
|
||||
this.isExcluded = isExcluded;
|
||||
return;
|
||||
}
|
||||
subExclusions.computeIfAbsent(packageNameSegments[0], packageName -> new ClassExclusions())
|
||||
.setPackageExclusion(Arrays.copyOfRange(packageNameSegments, 1, packageNameSegments.length),
|
||||
isExcluded);
|
||||
}
|
||||
|
||||
public void setClassExclusion(String[] classNameSegments, boolean isExcluded) {
|
||||
if (classNameSegments == null || classNameSegments.length < 1) {
|
||||
return;
|
||||
}
|
||||
if (classNameSegments.length == 1) {
|
||||
classExclusions.put(classNameSegments[0], isExcluded);
|
||||
} else {
|
||||
subExclusions.computeIfAbsent(classNameSegments[0], packageName -> new ClassExclusions())
|
||||
.setClassExclusion(Arrays.copyOfRange(classNameSegments, 1, classNameSegments.length),
|
||||
isExcluded);
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean isExcluded(String[] classNameSegments) {
|
||||
if (classNameSegments == null || classNameSegments.length < 1) {
|
||||
return isExcluded;
|
||||
}
|
||||
if (classNameSegments.length == 1) {
|
||||
final Boolean isClassExcluded = classExclusions.get(classNameSegments[0]);
|
||||
return isClassExcluded != null ? isClassExcluded : isExcluded != null ? isExcluded : isSubpackagesExcluded;
|
||||
}
|
||||
ClassExclusions subPackageExclusions = subExclusions.get(classNameSegments[0]);
|
||||
if (subPackageExclusions != null) {
|
||||
Boolean isExcluded = subPackageExclusions
|
||||
.isExcluded(Arrays.copyOfRange(classNameSegments, 1, classNameSegments.length));
|
||||
return isExcluded != null ? isExcluded : isSubpackagesExcluded;
|
||||
}
|
||||
return isSubpackagesExcluded;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ClassMappings implements Function<String, List<String>> {
|
||||
private final Map<String, List<String>> mappedClassNames = new LinkedHashMap<>();
|
||||
private final List<String> mappedPackageNames = new LinkedList<>();
|
||||
private final List<String> mappedPackageHierarchyNames = new LinkedList<>();
|
||||
private final Map<String, ClassMappings> subMappings = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public List<String> apply(String className) {
|
||||
List<String> mappings = new LinkedList<>();
|
||||
getMappingsInto(className.split("\\."), mappings);
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public void addPackageHierarchyMappingRule(String[] packageNameSegments, String mappedPackageName) {
|
||||
if (packageNameSegments == null || packageNameSegments.length < 1) {
|
||||
mappedPackageHierarchyNames.add(mappedPackageName);
|
||||
} else {
|
||||
subMappings.computeIfAbsent(packageNameSegments[0], packageName -> new ClassMappings())
|
||||
.addPackageHierarchyMappingRule(
|
||||
Arrays.copyOfRange(packageNameSegments, 1, packageNameSegments.length),
|
||||
mappedPackageName);
|
||||
}
|
||||
}
|
||||
|
||||
public void addPackageMappingRule(String[] packageNameSegments, String mappedPackageName) {
|
||||
if (packageNameSegments == null || packageNameSegments.length < 1) {
|
||||
mappedPackageNames.add(mappedPackageName);
|
||||
} else {
|
||||
subMappings.computeIfAbsent(packageNameSegments[0], packageName -> new ClassMappings())
|
||||
.addPackageMappingRule(Arrays.copyOfRange(packageNameSegments, 1, packageNameSegments.length),
|
||||
mappedPackageName);
|
||||
}
|
||||
}
|
||||
|
||||
public void addClassMappingRule(String[] classNameSegments, String mappedClassName) {
|
||||
if (classNameSegments == null || classNameSegments.length < 1) {
|
||||
return;
|
||||
}
|
||||
if (classNameSegments.length == 1) {
|
||||
mappedClassNames.computeIfAbsent(classNameSegments[0], simpleClassName -> new LinkedList<>())
|
||||
.add(mappedClassName);
|
||||
return;
|
||||
}
|
||||
subMappings.computeIfAbsent(classNameSegments[0], packageName -> new ClassMappings())
|
||||
.addClassMappingRule(Arrays.copyOfRange(classNameSegments, 1, classNameSegments.length),
|
||||
mappedClassName);
|
||||
}
|
||||
|
||||
private void getMappingsInto(String[] classNameSegments, List<String> mappings) {
|
||||
if (classNameSegments == null || classNameSegments.length < 1) {
|
||||
return;
|
||||
}
|
||||
if (classNameSegments.length == 1) {
|
||||
final List<String> classNameMappings = mappedClassNames.get(classNameSegments[0]);
|
||||
if (classNameMappings != null) {
|
||||
mappings.addAll(classNameMappings);
|
||||
}
|
||||
if (!mappedPackageNames.isEmpty()) {
|
||||
String mappingSuffix = "." + classNameSegments[0];
|
||||
for (String packageName : mappedPackageNames) {
|
||||
mappings.add(packageName + mappingSuffix);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ClassMappings classMappings = subMappings.get(classNameSegments[0]);
|
||||
if (classMappings != null) {
|
||||
classMappings
|
||||
.getMappingsInto(Arrays.copyOfRange(classNameSegments, 1, classNameSegments.length), mappings);
|
||||
}
|
||||
}
|
||||
if (!mappedPackageHierarchyNames.isEmpty()) {
|
||||
String mappingSuffix = "." + String.join(".", classNameSegments);
|
||||
for (String packageName : mappedPackageHierarchyNames) {
|
||||
mappings.add(packageName + mappingSuffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
public class OrderedProperties extends Properties {
|
||||
private Vector<Object> keys;
|
||||
|
||||
public OrderedProperties() {
|
||||
keys = new Vector<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object put(Object key, Object value) {
|
||||
keys.remove(key);
|
||||
keys.add(key);
|
||||
return super.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<?> propertyNames() {
|
||||
return keys.elements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> stringPropertyNames() {
|
||||
Set<String> stringPropertyNames = new LinkedHashSet<>(keys.size());
|
||||
for (Object key : keys) {
|
||||
if (key instanceof String) {
|
||||
stringPropertyNames.add((String) key);
|
||||
}
|
||||
}
|
||||
return stringPropertyNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(Object key) {
|
||||
keys.remove(key);
|
||||
return super.remove(key);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PrefixMapping implements Function<String, String> {
|
||||
private String packageClassPrefix;
|
||||
private String packageHierarchyClassPrefix;
|
||||
private final Map<String, PrefixMapping> subMappings = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public String apply(String className) {
|
||||
final String prefix = getPrefix(className.split("\\."));
|
||||
return prefix != null ? new StringBuilder(className).insert(className.lastIndexOf(".") + 1, prefix)
|
||||
.toString() : className;
|
||||
}
|
||||
|
||||
public String revert(String className) {
|
||||
final String prefix = getPrefix(className.split("\\."));
|
||||
return prefix != null ? new StringBuilder(className)
|
||||
.delete(className.lastIndexOf(".") + 1, className.lastIndexOf(".") + 1 + prefix.length()).toString()
|
||||
: className;
|
||||
}
|
||||
|
||||
public void setPackageHierarchyClassPrefixRule(String[] packageNameSegments, String classPrefix) {
|
||||
if (packageNameSegments == null || packageNameSegments.length < 1) {
|
||||
packageHierarchyClassPrefix = classPrefix;
|
||||
} else {
|
||||
subMappings.computeIfAbsent(packageNameSegments[0], s -> new PrefixMapping())
|
||||
.setPackageHierarchyClassPrefixRule(
|
||||
Arrays.copyOfRange(packageNameSegments, 1, packageNameSegments.length), classPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPackageClassPrefixRule(String[] packageNameSegments, String classPrefix) {
|
||||
if (packageNameSegments == null || packageNameSegments.length < 1) {
|
||||
packageClassPrefix = classPrefix;
|
||||
} else {
|
||||
subMappings.computeIfAbsent(packageNameSegments[0], s -> new PrefixMapping())
|
||||
.setPackageClassPrefixRule(
|
||||
Arrays.copyOfRange(packageNameSegments, 1, packageNameSegments.length), classPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
private String getPrefix(String[] classNameSegments) {
|
||||
if (classNameSegments == null || classNameSegments.length <= 1) {
|
||||
return packageClassPrefix != null ? packageClassPrefix : packageHierarchyClassPrefix;
|
||||
}
|
||||
final PrefixMapping prefixMapping = subMappings.get(classNameSegments[0]);
|
||||
if (prefixMapping != null) {
|
||||
final String prefix =
|
||||
prefixMapping.getPrefix(Arrays.copyOfRange(classNameSegments, 1, classNameSegments.length));
|
||||
return prefix != null ? prefix : packageHierarchyClassPrefix;
|
||||
}
|
||||
return packageHierarchyClassPrefix;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.teavm.junit.SkipJVM;
|
||||
import org.teavm.junit.TeaVMTestRunner;
|
||||
import org.teavm.junit.WholeClassCompilation;
|
||||
import org.teavm.parsing.substitution.java.RootPackageClass1;
|
||||
import org.teavm.parsing.substitution.java.RootPackageClass2;
|
||||
import org.teavm.parsing.substitution.java.RootPackageClass3;
|
||||
import org.teavm.parsing.substitution.java.RootPackageClass4;
|
||||
import org.teavm.parsing.substitution.java.excludedhierarchy.ExcludedPackageClass1;
|
||||
import org.teavm.parsing.substitution.java.excludedhierarchy.excludedsubpackage.ExcludedSubPackageClass;
|
||||
import org.teavm.parsing.substitution.java.excludedhierarchy.excludedsubpackage.IncludedSubPackageClass;
|
||||
import org.teavm.parsing.substitution.java.excludedpackage.ExcludedPackageClass2;
|
||||
import org.teavm.parsing.substitution.java.excludedpackage.excludedsubpackage.NotExcludedSubPackageClass;
|
||||
import org.teavm.parsing.substitution.java.subpackage.ExcludedClass;
|
||||
import org.teavm.parsing.substitution.java.subpackage.SubPackageClass1;
|
||||
import org.teavm.parsing.substitution.java.subpackage.SubPackageClass2;
|
||||
import org.teavm.parsing.substitution.java.subpackage.SubPackageClass3;
|
||||
import org.teavm.parsing.substitution.java.subpackage.SubPackageClass4;
|
||||
import org.teavm.parsing.substitution.java.subpackage.subsubpackage.SubSubPackageClass1;
|
||||
|
||||
@RunWith(TeaVMTestRunner.class)
|
||||
@WholeClassCompilation
|
||||
@SkipJVM
|
||||
public class ClasspathResourceMapperTest {
|
||||
@Test
|
||||
public void classesInPackageHierarchyMappingAreSubstituted() {
|
||||
assertEquals("RootPackageClass1Substitute", new RootPackageClass1().getIdentifier());
|
||||
assertEquals("SubPackageClass1Substitute", new SubPackageClass1().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classesInPackageMappingAreSubstituted() {
|
||||
assertEquals("RootPackageClass2Substitute", new RootPackageClass2().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classesOutsidePackageMappingAreNotSubstituted() {
|
||||
assertEquals("SubPackageClass2", new SubPackageClass2().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specificClassMappingsAreSubstituted() {
|
||||
assertEquals("SubSubPackageClassSubstitute", new SubSubPackageClass1().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixedClassesInPackageHierarchyMappingAreSubstituted() {
|
||||
assertEquals("RootPackageClass3Substitute", new RootPackageClass3().getIdentifier());
|
||||
assertEquals("SubPackageClass3Substitute", new SubPackageClass3().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixedClassesInPackageMappingAreSubstituted() {
|
||||
assertEquals("RootPackageClass4Substitute", new RootPackageClass4().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixedClassesOutsidePackageMappingAreNotSubstituted() {
|
||||
assertEquals("SubPackageClass4", new SubPackageClass4().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludedClassesInPackageHierarchyMappingAreNotSubstituted() {
|
||||
assertEquals("ExcludedPackageClass1", new ExcludedPackageClass1().getIdentifier());
|
||||
assertEquals("ExcludedSubPackageClass", new ExcludedSubPackageClass().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludedClassesInPackageMappingAreNotSubstituted() {
|
||||
assertEquals("ExcludedPackageClass2", new ExcludedPackageClass2().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classesOutsidePackageMappingExclusionAreSubstituted() {
|
||||
assertEquals("NotExcludedSubPackageClassSubstitute", new NotExcludedSubPackageClass().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void individualIncludedClassesInPackageHierarchyMappingExclusionAreSubstituted() {
|
||||
assertEquals("IncludedSubPackageClassSubstitute", new IncludedSubPackageClass().getIdentifier());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void individualExcludedClassesInPackageHierarchyMappingAreNotSubstituted() {
|
||||
assertEquals("ExcludedClass", new ExcludedClass().getIdentifier());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib;
|
||||
|
||||
public class SubSubPackageClassSubstitute {
|
||||
public String getIdentifier() {
|
||||
return "SubSubPackageClassSubstitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.packagehierarchysubstitution;
|
||||
|
||||
public class RootPackageClass1 {
|
||||
public String getIdentifier() {
|
||||
return "RootPackageClass1Substitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.excludedhierarchy;
|
||||
|
||||
public class ExcludedPackageClass1 {
|
||||
public String getIdentifier() {
|
||||
return "ExcludedPackageClass1Substitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.excludedhierarchy.excludedsubpackage;
|
||||
|
||||
public class ExcludedSubPackageClass {
|
||||
public String getIdentifier() {
|
||||
return "ExcludedSubPackageClassSubstitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.excludedhierarchy.excludedsubpackage;
|
||||
|
||||
public class IncludedSubPackageClass {
|
||||
public String getIdentifier() {
|
||||
return "IncludedSubPackageClassSubstitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.excludedpackage;
|
||||
|
||||
public class ExcludedPackageClass2 {
|
||||
public String getIdentifier() {
|
||||
return "ExcludedPackageClass2Substitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.excludedpackage.excludedsubpackage;
|
||||
|
||||
public class NotExcludedSubPackageClass {
|
||||
public String getIdentifier() {
|
||||
return "NotExcludedSubPackageClassSubstitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.subpackage;
|
||||
|
||||
public class ExcludedClass {
|
||||
public String getIdentifier() {
|
||||
return "ExcludedClassSubstitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.subpackage;
|
||||
|
||||
public class SubPackageClass1 {
|
||||
public String getIdentifier() {
|
||||
return "SubPackageClass1Substitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.packagesubstitution;
|
||||
|
||||
public class RootPackageClass2 {
|
||||
public String getIdentifier() {
|
||||
return "RootPackageClass2Substitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.packagesubstitution.subpackage;
|
||||
|
||||
public class SubPackageClass2 {
|
||||
public String getIdentifier() {
|
||||
return "SubPackageClass2Substitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.prefixed.packagehierarchysubstitution;
|
||||
|
||||
public class PrefixedRootPackageClass3 {
|
||||
public String getIdentifier() {
|
||||
return "RootPackageClass3Substitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.prefixed.packagehierarchysubstitution.subpackage;
|
||||
|
||||
public class PrefixedSubPackageClass3 {
|
||||
public String getIdentifier() {
|
||||
return "SubPackageClass3Substitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.prefixed.packagesubstitution;
|
||||
|
||||
public class PrefixedRootPackageClass4 {
|
||||
public String getIdentifier() {
|
||||
return "RootPackageClass4Substitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.classlib.prefixed.packagesubstitution.subpackage;
|
||||
|
||||
public class PrefixedSubPackageClass4 {
|
||||
public String getIdentifier() {
|
||||
return "SubPackageClass4Substitute";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java;
|
||||
|
||||
public class RootPackageClass1 {
|
||||
public String getIdentifier() {
|
||||
return "RootPackageClass1";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java;
|
||||
|
||||
public class RootPackageClass2 {
|
||||
public String getIdentifier() {
|
||||
return "RootPackageClass2";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java;
|
||||
|
||||
public class RootPackageClass3 {
|
||||
public String getIdentifier() {
|
||||
return "RootPackageClass3";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java;
|
||||
|
||||
public class RootPackageClass4 {
|
||||
public String getIdentifier() {
|
||||
return "RootPackageClass4";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.excludedhierarchy;
|
||||
|
||||
public class ExcludedPackageClass1 {
|
||||
public String getIdentifier() {
|
||||
return "ExcludedPackageClass1";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.excludedhierarchy.excludedsubpackage;
|
||||
|
||||
public class ExcludedSubPackageClass {
|
||||
public String getIdentifier() {
|
||||
return "ExcludedSubPackageClass";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.excludedhierarchy.excludedsubpackage;
|
||||
|
||||
public class IncludedSubPackageClass {
|
||||
public String getIdentifier() {
|
||||
return "IncludedSubPackageClass";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.excludedpackage;
|
||||
|
||||
public class ExcludedPackageClass2 {
|
||||
public String getIdentifier() {
|
||||
return "ExcludedPackageClass2";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.excludedpackage.excludedsubpackage;
|
||||
|
||||
public class NotExcludedSubPackageClass {
|
||||
public String getIdentifier() {
|
||||
return "NotExcludedSubPackageClass";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.subpackage;
|
||||
|
||||
public class ExcludedClass {
|
||||
public String getIdentifier() {
|
||||
return "ExcludedClass";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.subpackage;
|
||||
|
||||
public class SubPackageClass1 {
|
||||
public String getIdentifier() {
|
||||
return "SubPackageClass1";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.subpackage;
|
||||
|
||||
public class SubPackageClass2 {
|
||||
public String getIdentifier() {
|
||||
return "SubPackageClass2";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.subpackage;
|
||||
|
||||
public class SubPackageClass3 {
|
||||
public String getIdentifier() {
|
||||
return "SubPackageClass3";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.subpackage;
|
||||
|
||||
public class SubPackageClass4 {
|
||||
public String getIdentifier() {
|
||||
return "SubPackageClass4";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright 2020 adam.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package org.teavm.parsing.substitution.java.subpackage.subsubpackage;
|
||||
|
||||
public class SubSubPackageClass1 {
|
||||
public String getIdentifier() {
|
||||
return "SubSubPackageClass";
|
||||
}
|
||||
}
|
1
tests/src/test/js/.gitignore
vendored
1
tests/src/test/js/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/node_modules/
|
||||
/bin/
|
||||
/tmp/
|
||||
package-lock.json
|
26
tests/src/test/resources/META-INF/teavm.properties
Normal file
26
tests/src/test/resources/META-INF/teavm.properties
Normal file
|
@ -0,0 +1,26 @@
|
|||
#
|
||||
# Copyright 2020 adam.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
mapPackageHierarchy|org.teavm.parsing.substitution.classlib.packagehierarchysubstitution=org.teavm.parsing.substitution.java
|
||||
mapPackage|org.teavm.parsing.substitution.classlib.packagesubstitution=org.teavm.parsing.substitution.java
|
||||
mapClass|org.teavm.parsing.substitution.classlib.SubSubPackageClassSubstitute=org.teavm.parsing.substitution.java.subpackage.subsubpackage.SubSubPackageClass1
|
||||
mapPackageHierarchy|org.teavm.parsing.substitution.classlib.prefixed.packagehierarchysubstitution=org.teavm.parsing.substitution.java
|
||||
stripPrefixFromPackageHierarchyClasses|org.teavm.parsing.substitution.classlib.prefixed.packagehierarchysubstitution=Prefixed
|
||||
mapPackage|org.teavm.parsing.substitution.classlib.prefixed.packagesubstitution=org.teavm.parsing.substitution.java
|
||||
stripPrefixFromPackageClasses|org.teavm.parsing.substitution.classlib.prefixed.packagesubstitution=Prefixed
|
||||
includePackageHierarchy|org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.excludedhierarchy=false
|
||||
includePackage|org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.excludedpackage=false
|
||||
includeClass|org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.excludedhierarchy.excludedsubpackage.IncludedSubPackageClass=true
|
||||
includeClass|org.teavm.parsing.substitution.classlib.packagehierarchysubstitution.subpackage.ExcludedClass=false
|
Loading…
Reference in New Issue
Block a user