From 25011ee7a6e5f6e1ffc4a2bd00e2ca2f7fad072c Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sun, 29 Oct 2017 21:41:49 +0300 Subject: [PATCH] Remove outdated hack when Class.parent could be non-null for root classes --- .../org/teavm/backend/wasm/generate/WasmClassGenerator.java | 4 ++-- .../main/java/org/teavm/dependency/DependencyChecker.java | 4 ++-- core/src/main/java/org/teavm/model/ClassReaderSource.java | 4 ++-- core/src/main/java/org/teavm/model/classes/TagRegistry.java | 2 +- .../org/teavm/model/lowlevel/ClassInitializerEliminator.java | 2 +- .../main/java/org/teavm/model/util/AsyncMethodFinder.java | 4 ++-- .../src/main/java/org/teavm/jso/impl/JSClassProcessor.java | 5 ++--- .../java/org/teavm/jso/impl/JSObjectClassTransformer.java | 2 +- jso/impl/src/main/java/org/teavm/jso/impl/JSTypeHelper.java | 4 ++-- 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java index 09852ebaf..3290f3754 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmClassGenerator.java @@ -302,7 +302,7 @@ public class WasmClassGenerator { if (cls.getName().equals(Structure.class.getName()) || cls.getName().equals(Function.class.getName())) { return false; } - if (cls.getParent() == null || cls.getParent().equals(cls.getName())) { + if (cls.getParent() == null) { return true; } cls = classSource.get(cls.getParent()); @@ -385,7 +385,7 @@ public class WasmClassGenerator { data.start = -1; data.function = true; return; - } else if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { + } else if (cls.getParent() != null) { addClass(ValueType.object(cls.getParent())); ClassBinaryData parentData = binaryDataMap.get(ValueType.object(cls.getParent())); data.size = parentData.size; diff --git a/core/src/main/java/org/teavm/dependency/DependencyChecker.java b/core/src/main/java/org/teavm/dependency/DependencyChecker.java index 676d16046..38585fa2b 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyChecker.java +++ b/core/src/main/java/org/teavm/dependency/DependencyChecker.java @@ -292,7 +292,7 @@ public class DependencyChecker implements DependencyInfo { } ClassReader cls = classSource.get(className); if (cls != null) { - if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { + if (cls.getParent() != null) { addClassAccess(node, cls.getParent(), loc); } for (String iface : cls.getInterfaces()) { @@ -306,7 +306,7 @@ public class DependencyChecker implements DependencyInfo { ClassReader cls = classSource.get(className); ClassDependency dependency = new ClassDependency(this, className, cls); if (!dependency.isMissing()) { - if (cls.getParent() != null && !cls.getParent().equals(className)) { + if (cls.getParent() != null) { linkClass(cls.getParent(), null); } for (String ifaceName : cls.getInterfaces()) { diff --git a/core/src/main/java/org/teavm/model/ClassReaderSource.java b/core/src/main/java/org/teavm/model/ClassReaderSource.java index 8b4d588ce..49a48ff40 100644 --- a/core/src/main/java/org/teavm/model/ClassReaderSource.java +++ b/core/src/main/java/org/teavm/model/ClassReaderSource.java @@ -33,7 +33,7 @@ public interface ClassReaderSource { ClassReader currentClass = get(name); @Override public ClassReader next() { ClassReader result = currentClass; - if (currentClass.getParent() != null && !currentClass.getName().equals(currentClass.getParent())) { + if (currentClass.getParent() != null) { currentClass = get(currentClass.getParent()); } else { currentClass = null; @@ -120,7 +120,7 @@ public interface ClassReaderSource { if (cls == null) { return Optional.empty(); } - if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { + if (cls.getParent() != null) { if (isSuperType(superType, cls.getParent()).orElse(false)) { return Optional.of(true); } diff --git a/core/src/main/java/org/teavm/model/classes/TagRegistry.java b/core/src/main/java/org/teavm/model/classes/TagRegistry.java index c2d78caca..38b711e9a 100644 --- a/core/src/main/java/org/teavm/model/classes/TagRegistry.java +++ b/core/src/main/java/org/teavm/model/classes/TagRegistry.java @@ -94,7 +94,7 @@ public class TagRegistry { return null; } - if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { + if (cls.getParent() != null) { String candidate = findTopmostImplementor(classSource, cls.getParent(), ifaceName); if (candidate != null) { return candidate; diff --git a/core/src/main/java/org/teavm/model/lowlevel/ClassInitializerEliminator.java b/core/src/main/java/org/teavm/model/lowlevel/ClassInitializerEliminator.java index fab5328f0..89affc009 100644 --- a/core/src/main/java/org/teavm/model/lowlevel/ClassInitializerEliminator.java +++ b/core/src/main/java/org/teavm/model/lowlevel/ClassInitializerEliminator.java @@ -75,7 +75,7 @@ public class ClassInitializerEliminator { if (cls == null) { return false; } - if (cls.getParent() == null || cls.getName().equals(cls.getParent())) { + if (cls.getParent() == null) { return false; } className = cls.getParent(); diff --git a/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java b/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java index 926919d7f..94d16306c 100644 --- a/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java +++ b/core/src/main/java/org/teavm/model/util/AsyncMethodFinder.java @@ -235,7 +235,7 @@ public class AsyncMethodFinder { private Set findOverriddenMethods(ClassReader cls, MethodReference methodRef) { List parents = new ArrayList<>(); - if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { + if (cls.getParent() != null) { parents.add(cls.getParent()); } parents.addAll(cls.getInterfaces()); @@ -266,7 +266,7 @@ public class AsyncMethodFinder { result.add(methodRef); } } else { - if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { + if (cls.getParent() != null) { findOverriddenMethods(new MethodReference(cls.getParent(), methodRef.getDescriptor()), result, visited); } for (String iface : cls.getInterfaces()) { diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java index 29e0ee7a2..71e38ae19 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSClassProcessor.java @@ -213,7 +213,7 @@ class JSClassProcessor { } } } else if (typeHelper.isJavaScriptImplementation(cls.getName())) { - if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { + if (cls.getParent() != null) { ClassReader parentCls = classSource.get(cls.getParent()); if (parentCls != null) { findInheritedMethods(parentCls, methods, visited); @@ -718,8 +718,7 @@ class JSClassProcessor { if (method != null) { return method; } - if (cls.getParent() != null && !cls.getParent().equals(cls.getName()) - && !cls.getParent().equals("java.lang.Object")) { + if (cls.getParent() != null && !cls.getParent().equals("java.lang.Object")) { method = getMethod(new MethodReference(cls.getParent(), ref.getDescriptor())); if (method != null) { return method; diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSObjectClassTransformer.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSObjectClassTransformer.java index 89a55902b..d075aa618 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSObjectClassTransformer.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSObjectClassTransformer.java @@ -184,7 +184,7 @@ class JSObjectClassTransformer implements ClassHolderTransformer { if (cls.hasModifier(ElementModifier.INTERFACE)) { return; } - if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { + if (cls.getParent() != null) { ExposedClass parent = getExposedClass(cls.getParent()); exposedCls.inheritedMethods.putAll(parent.inheritedMethods); exposedCls.inheritedMethods.putAll(parent.methods); diff --git a/jso/impl/src/main/java/org/teavm/jso/impl/JSTypeHelper.java b/jso/impl/src/main/java/org/teavm/jso/impl/JSTypeHelper.java index c6690d93c..84bbdd6bd 100644 --- a/jso/impl/src/main/java/org/teavm/jso/impl/JSTypeHelper.java +++ b/jso/impl/src/main/java/org/teavm/jso/impl/JSTypeHelper.java @@ -47,7 +47,7 @@ class JSTypeHelper { if (cls == null || !(cls.hasModifier(ElementModifier.INTERFACE) || cls.hasModifier(ElementModifier.ABSTRACT))) { return false; } - if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { + if (cls.getParent() != null) { if (isJavaScriptClass(cls.getParent())) { return true; } @@ -63,7 +63,7 @@ class JSTypeHelper { if (cls == null) { return false; } - if (cls.getParent() != null && !cls.getParent().equals(cls.getName())) { + if (cls.getParent() != null) { if (isJavaScriptClass(cls.getParent())) { return true; }