diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 2bf838622..ae1ba08c1 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -26,6 +26,7 @@
+
@@ -52,6 +53,7 @@
+
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index 0272c80a3..ed855c95f 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -9,7 +9,8 @@
-
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 6f86e5810..5ed40ff95 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -45,7 +45,8 @@
-
+
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index f1e38179a..a259e2964 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,6 +3,7 @@
+
@@ -19,7 +20,7 @@
-
+
diff --git a/classlib/teavm-classlib.iml b/classlib/teavm-classlib.iml
index 3769e7ea4..ead5bc4ab 100644
--- a/classlib/teavm-classlib.iml
+++ b/classlib/teavm-classlib.iml
@@ -14,7 +14,7 @@
-
+
diff --git a/core/src/main/java/org/teavm/vm/TeaVM.java b/core/src/main/java/org/teavm/vm/TeaVM.java
index d331bcebe..35d5ed6bd 100644
--- a/core/src/main/java/org/teavm/vm/TeaVM.java
+++ b/core/src/main/java/org/teavm/vm/TeaVM.java
@@ -31,7 +31,6 @@ import org.teavm.javascript.spi.GeneratedBy;
import org.teavm.javascript.spi.Generator;
import org.teavm.javascript.spi.InjectedBy;
import org.teavm.javascript.spi.Injector;
-import org.teavm.metaprogramming.impl.MetaprogrammingDependencyListener;
import org.teavm.model.*;
import org.teavm.model.instructions.*;
import org.teavm.model.util.*;
@@ -356,8 +355,6 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
return;
}
- dependencyChecker.addDependencyListener(new MetaprogrammingDependencyListener());
-
AliasProvider aliasProvider = minifying ? new MinifyingAliasProvider() : new DefaultAliasProvider();
dependencyChecker.setInterruptor(() -> progressListener.progressReached(0) == TeaVMProgressFeedback.CONTINUE);
dependencyChecker.linkMethod(new MethodReference(Class.class.getName(), "getClass",
diff --git a/metaprogramming-api/pom.xml b/metaprogramming/api/pom.xml
similarity index 93%
rename from metaprogramming-api/pom.xml
rename to metaprogramming/api/pom.xml
index 122af3be8..a001bd06e 100644
--- a/metaprogramming-api/pom.xml
+++ b/metaprogramming/api/pom.xml
@@ -24,6 +24,7 @@
org.teavm
teavm
1.0.0-SNAPSHOT
+ ../..
teavm-metaprogramming-api
@@ -46,7 +47,8 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- ../checkstyle.xml
+ ../../checkstyle.xml
+ config_loc=${basedir}/../..
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/Action.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/Action.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/Action.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/Action.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/CompileTime.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/CompileTime.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/CompileTime.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/CompileTime.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/Computation.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/Computation.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/Computation.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/Computation.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/Diagnostics.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/Diagnostics.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/Diagnostics.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/Diagnostics.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/InvocationHandler.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/InvocationHandler.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/InvocationHandler.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/InvocationHandler.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/LazyComputation.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/LazyComputation.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/LazyComputation.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/LazyComputation.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/Meta.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/Meta.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/Meta.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/Meta.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/Metaprogramming.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/Metaprogramming.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/Metaprogramming.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/Metaprogramming.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/ReflectClass.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/ReflectClass.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/ReflectClass.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/ReflectClass.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/SourceLocation.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/SourceLocation.java
similarity index 94%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/SourceLocation.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/SourceLocation.java
index 74877ae8f..c5c72254d 100644
--- a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/SourceLocation.java
+++ b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/SourceLocation.java
@@ -66,6 +66,7 @@ public class SourceLocation {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(method.getName());
- return lineNumber > 0 ? fileName + ":" + lineNumber : fileName;
+ sb.append(lineNumber > 0 ? fileName + ":" + lineNumber : fileName);
+ return sb.toString();
}
}
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/Value.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/Value.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/Value.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/Value.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/reflect/ReflectAnnotatedElement.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/reflect/ReflectAnnotatedElement.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/reflect/ReflectAnnotatedElement.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/reflect/ReflectAnnotatedElement.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/reflect/ReflectField.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/reflect/ReflectField.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/reflect/ReflectField.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/reflect/ReflectField.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/reflect/ReflectMember.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/reflect/ReflectMember.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/reflect/ReflectMember.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/reflect/ReflectMember.java
diff --git a/metaprogramming-api/src/main/java/org/teavm/metaprogramming/reflect/ReflectMethod.java b/metaprogramming/api/src/main/java/org/teavm/metaprogramming/reflect/ReflectMethod.java
similarity index 100%
rename from metaprogramming-api/src/main/java/org/teavm/metaprogramming/reflect/ReflectMethod.java
rename to metaprogramming/api/src/main/java/org/teavm/metaprogramming/reflect/ReflectMethod.java
diff --git a/metaprogramming-api/teavm-metaprogramming-api.iml b/metaprogramming/api/teavm-metaprogramming-api.iml
similarity index 95%
rename from metaprogramming-api/teavm-metaprogramming-api.iml
rename to metaprogramming/api/teavm-metaprogramming-api.iml
index 48e1bc5e6..146ecceee 100644
--- a/metaprogramming-api/teavm-metaprogramming-api.iml
+++ b/metaprogramming/api/teavm-metaprogramming-api.iml
@@ -17,7 +17,6 @@
-
diff --git a/metaprogramming/impl/impl.iml b/metaprogramming/impl/impl.iml
new file mode 100644
index 000000000..a7b1b7d81
--- /dev/null
+++ b/metaprogramming/impl/impl.iml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/metaprogramming/impl/pom.xml b/metaprogramming/impl/pom.xml
new file mode 100644
index 000000000..606cdb9e7
--- /dev/null
+++ b/metaprogramming/impl/pom.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+ teavm
+ org.teavm
+ 1.0.0-SNAPSHOT
+ ../../pom.xml
+
+ 4.0.0
+
+ teavm-metaprogramming-impl
+
+ bundle
+
+ TeaVM metaprogramming API implementation
+ Implementation of metaprogramming API
+
+
+
+ org.teavm
+ teavm-core
+ ${project.version}
+
+
+ org.teavm
+ teavm-metaprogramming-api
+ ${project.version}
+
+
+ junit
+ junit
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+ ../../checkstyle.xml
+ config_loc=${basedir}/../..
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ true
+
+
+ org.teavm.metaprogramming.*
+ teavm-metaprogramming-api
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/ActionImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/ActionImpl.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/ActionImpl.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/ActionImpl.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java
similarity index 94%
rename from core/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java
index 038e2161b..07f2beb81 100644
--- a/core/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/AliasFinder.java
@@ -42,16 +42,11 @@ import org.teavm.model.instructions.InvocationType;
import org.teavm.model.instructions.NumericOperandType;
import org.teavm.model.instructions.SwitchTableEntryReader;
-/**
- *
- * @author Alexey Andreev
- */
-public class AliasFinder {
- int[] aliases;
- Object[] constants;
- ArrayElement[] arrayElements;
+class AliasFinder {
+ private int[] aliases;
+ private ArrayElement[] arrayElements;
- public void findAliases(ProgramReader program) {
+ void findAliases(ProgramReader program) {
DisjointSet set = new DisjointSet();
for (int i = 0; i < program.variableCount(); ++i) {
set.create();
@@ -85,7 +80,7 @@ public class AliasFinder {
}
aliases = variables;
- constants = reader.constants;
+ Object[] constants = reader.constants;
arrayElements = reader.arrayElements;
for (int i = 0; i < arrayElements.length; ++i) {
@@ -102,29 +97,25 @@ public class AliasFinder {
}
}
- public static class ArrayElement {
+ static class ArrayElement {
public int array;
public int index;
}
- public int[] getAliases() {
+ int[] getAliases() {
return aliases.clone();
}
- public Object[] getConstants() {
- return constants.clone();
- }
-
- public ArrayElement[] getArrayElements() {
+ ArrayElement[] getArrayElements() {
return arrayElements.clone();
}
- static class AliasReader implements InstructionReader {
+ private static class AliasReader implements InstructionReader {
DisjointSet disjointSet;
Object[] constants;
ArrayElement[] arrayElements;
- AliasReader(DisjointSet disjointSet, int variableCount) {
+ private AliasReader(DisjointSet disjointSet, int variableCount) {
this.disjointSet = disjointSet;
this.constants = new Object[variableCount];
this.arrayElements = new ArrayElement[variableCount];
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/CapturedValue.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CapturedValue.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/CapturedValue.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CapturedValue.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java
similarity index 99%
rename from core/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java
index 739995432..1e4062338 100644
--- a/core/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/CompositeMethodGenerator.java
@@ -26,7 +26,6 @@ import java.util.stream.Stream;
import org.teavm.diagnostics.Diagnostics;
import org.teavm.metaprogramming.ReflectClass;
import org.teavm.metaprogramming.Value;
-import org.teavm.metaprogramming.impl.AliasFinder.ArrayElement;
import org.teavm.metaprogramming.impl.reflect.ReflectClassImpl;
import org.teavm.metaprogramming.impl.reflect.ReflectFieldImpl;
import org.teavm.metaprogramming.impl.reflect.ReflectMethodImpl;
@@ -454,10 +453,10 @@ public class CompositeMethodGenerator {
private int variableOffset;
int[] variableMapping;
CapturedValue[] capturedValues;
- ArrayElement[] arrayElements;
+ AliasFinder.ArrayElement[] arrayElements;
- TemplateSubstitutor(CapturedValue[] capturedValues, int[] variableMapping, ArrayElement[] arrayElements,
- int blockOffset, int variableOffset) {
+ TemplateSubstitutor(CapturedValue[] capturedValues, int[] variableMapping,
+ AliasFinder.ArrayElement[] arrayElements, int blockOffset, int variableOffset) {
this.capturedValues = capturedValues;
this.variableMapping = variableMapping;
this.arrayElements = arrayElements;
@@ -482,7 +481,7 @@ public class CompositeMethodGenerator {
if (capturedValues[index] != null) {
return captureValue(capturedValues[index]);
}
- ArrayElement elem = arrayElements[index];
+ AliasFinder.ArrayElement elem = arrayElements[index];
if (elem != null) {
int arrayVar = variableMapping[elem.array];
if (capturedValues[arrayVar] != null) {
@@ -770,7 +769,7 @@ public class CompositeMethodGenerator {
public void getElement(VariableReader receiver, VariableReader array, VariableReader index) {
int arrayIndex = variableMapping[array.getIndex()];
- ArrayElement elem = arrayElements[receiver.getIndex()];
+ AliasFinder.ArrayElement elem = arrayElements[receiver.getIndex()];
if (elem != null && capturedValues[arrayIndex] != null) {
AssignInstruction insn = new AssignInstruction();
insn.setAssignee(var(receiver));
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/ComputationImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/ComputationImpl.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/ComputationImpl.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/ComputationImpl.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/Fragment.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/Fragment.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/Fragment.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/Fragment.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/LazyValueImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/LazyValueImpl.java
similarity index 97%
rename from core/src/main/java/org/teavm/metaprogramming/impl/LazyValueImpl.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/LazyValueImpl.java
index 35392fb24..fe1bb6f0b 100644
--- a/core/src/main/java/org/teavm/metaprogramming/impl/LazyValueImpl.java
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/LazyValueImpl.java
@@ -20,10 +20,6 @@ import org.teavm.metaprogramming.Value;
import org.teavm.model.InstructionLocation;
import org.teavm.model.ValueType;
-/**
- *
- * @author Alexey Andreev
- */
public class LazyValueImpl implements Value {
boolean evaluated;
VariableContext context;
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingClassLoader.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingClassLoader.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingClassLoader.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingClassLoader.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingDependencyListener.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingDependencyListener.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingDependencyListener.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingDependencyListener.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java
similarity index 99%
rename from core/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java
index 8d6ce918a..da0e16830 100644
--- a/core/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingImpl.java
@@ -26,6 +26,7 @@ import org.teavm.metaprogramming.LazyComputation;
import org.teavm.metaprogramming.ReflectClass;
import org.teavm.metaprogramming.SourceLocation;
import org.teavm.metaprogramming.Value;
+import org.teavm.metaprogramming.impl.optimization.Optimizations;
import org.teavm.metaprogramming.impl.reflect.ReflectClassImpl;
import org.teavm.metaprogramming.impl.reflect.ReflectContext;
import org.teavm.metaprogramming.impl.reflect.ReflectFieldImpl;
@@ -277,7 +278,7 @@ public final class MetaprogrammingImpl {
jumpToStart.setTarget(program.basicBlockAt(startBlock.getIndex() + 1));
startBlock.getInstructions().add(jumpToStart);
- //new BoxingEliminator().optimize(program);
+ new Optimizations().apply(program);
cls.addMethod(methodHolder);
} finally {
returnType = returnTypeBackup;
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingInstrumentation.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingInstrumentation.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingInstrumentation.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingInstrumentation.java
diff --git a/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingPlugin.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingPlugin.java
new file mode 100644
index 000000000..3b50042af
--- /dev/null
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/MetaprogrammingPlugin.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2016 Alexey Andreev.
+ *
+ * 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.metaprogramming.impl;
+
+import org.teavm.vm.spi.TeaVMHost;
+import org.teavm.vm.spi.TeaVMPlugin;
+
+public class MetaprogrammingPlugin implements TeaVMPlugin {
+ @Override
+ public void install(TeaVMHost host) {
+ host.add(new MetaprogrammingDependencyListener());
+ }
+}
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/ProxyVariableContext.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/ProxyVariableContext.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/ProxyVariableContext.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/ProxyVariableContext.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/RuntimeHelper.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/RuntimeHelper.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/RuntimeHelper.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/RuntimeHelper.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/TopLevelVariableContext.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/TopLevelVariableContext.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/TopLevelVariableContext.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/TopLevelVariableContext.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/UsageGenerator.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/UsageGenerator.java
similarity index 99%
rename from core/src/main/java/org/teavm/metaprogramming/impl/UsageGenerator.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/UsageGenerator.java
index 0d200d119..dc5c404bc 100644
--- a/core/src/main/java/org/teavm/metaprogramming/impl/UsageGenerator.java
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/UsageGenerator.java
@@ -62,7 +62,7 @@ class UsageGenerator {
this.classLoader = classLoader;
}
- public void installProxyEmitter() {
+ void installProxyEmitter() {
Diagnostics diagnostics = agent.getDiagnostics();
try {
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/ValueImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/ValueImpl.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/ValueImpl.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/ValueImpl.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/VariableContext.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/VariableContext.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/VariableContext.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/VariableContext.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/model/MethodDescriber.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/model/MethodDescriber.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/model/MethodDescriber.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/model/MethodDescriber.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/model/MethodModel.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/model/MethodModel.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/model/MethodModel.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/model/MethodModel.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/optimization/BoxingElimination.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/optimization/BoxingElimination.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/optimization/BoxingElimination.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/optimization/BoxingElimination.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/optimization/Optimizations.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/optimization/Optimizations.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/optimization/Optimizations.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/optimization/Optimizations.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/AnnotationProxy.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/AnnotationProxy.java
similarity index 98%
rename from core/src/main/java/org/teavm/metaprogramming/impl/reflect/AnnotationProxy.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/AnnotationProxy.java
index dcbceb289..012dd1896 100644
--- a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/AnnotationProxy.java
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/AnnotationProxy.java
@@ -47,10 +47,6 @@ class AnnotationProxy implements InvocationHandler {
this.annotationType = annotationType;
}
- AnnotationProxy(AnnotationReader reader) {
- this.reader = reader;
- }
-
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("annotationType")) {
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectAnnotatedElementImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectAnnotatedElementImpl.java
similarity index 100%
rename from core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectAnnotatedElementImpl.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectAnnotatedElementImpl.java
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectClassImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectClassImpl.java
similarity index 99%
rename from core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectClassImpl.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectClassImpl.java
index dc3bef838..dc95e5a65 100644
--- a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectClassImpl.java
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectClassImpl.java
@@ -53,7 +53,7 @@ public class ReflectClassImpl implements ReflectClass {
this.context = context;
}
- public ReflectContext getReflectContext() {
+ ReflectContext getReflectContext() {
return context;
}
@@ -265,7 +265,7 @@ public class ReflectClassImpl implements ReflectClass {
});
}
- public ReflectMethodImpl getDeclaredMethod(MethodDescriptor method) {
+ private ReflectMethodImpl getDeclaredMethod(MethodDescriptor method) {
resolve();
return methods.computeIfAbsent(method, m -> {
MethodReader methodReader = classReader.getMethod(m);
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectContext.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectContext.java
similarity index 98%
rename from core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectContext.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectContext.java
index 5901257b0..27b6a7e60 100644
--- a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectContext.java
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectContext.java
@@ -24,10 +24,6 @@ import org.teavm.model.ElementModifier;
import org.teavm.model.ElementReader;
import org.teavm.model.ValueType;
-/**
- *
- * @author Alexey Andreev
- */
public class ReflectContext {
private ClassReaderSource classSource;
private Map> classes = new HashMap<>();
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectFieldImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectFieldImpl.java
similarity index 98%
rename from core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectFieldImpl.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectFieldImpl.java
index 37e20fd08..8267b0311 100644
--- a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectFieldImpl.java
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectFieldImpl.java
@@ -21,10 +21,6 @@ import org.teavm.metaprogramming.reflect.ReflectField;
import org.teavm.model.ElementModifier;
import org.teavm.model.FieldReader;
-/**
- *
- * @author Alexey Andreev
- */
public class ReflectFieldImpl implements ReflectField {
private ReflectContext context;
private ReflectClassImpl> declaringClass;
diff --git a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectMethodImpl.java b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectMethodImpl.java
similarity index 99%
rename from core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectMethodImpl.java
rename to metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectMethodImpl.java
index 8fba13ea9..7fcd013e8 100644
--- a/core/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectMethodImpl.java
+++ b/metaprogramming/impl/src/main/java/org/teavm/metaprogramming/impl/reflect/ReflectMethodImpl.java
@@ -24,10 +24,6 @@ import org.teavm.metaprogramming.reflect.ReflectAnnotatedElement;
import org.teavm.metaprogramming.reflect.ReflectMethod;
import org.teavm.model.MethodReader;
-/**
- *
- * @author Alexey Andreev
- */
public class ReflectMethodImpl implements ReflectMethod {
private ReflectContext context;
private ReflectClassImpl> declaringClass;
diff --git a/metaprogramming/impl/src/main/resources/META-INF/services/org.teavm.vm.spi.TeaVMPlugin b/metaprogramming/impl/src/main/resources/META-INF/services/org.teavm.vm.spi.TeaVMPlugin
new file mode 100644
index 000000000..c8c4e2395
--- /dev/null
+++ b/metaprogramming/impl/src/main/resources/META-INF/services/org.teavm.vm.spi.TeaVMPlugin
@@ -0,0 +1,17 @@
+#
+# Copyright 2016 Alexey Andreev.
+#
+# 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.
+#
+
+org.teavm.metaprogramming.impl.MetaprogrammingPlugin
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 48b53ddfe..f71cce6a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -79,7 +79,7 @@
- metaprogramming-api
+ metaprogramming/api
core
classlib
jso/core
@@ -95,6 +95,7 @@
tools/junit
tests
extras-slf4j
+ metaprogramming/impl
diff --git a/tests/pom.xml b/tests/pom.xml
index 797d3cc49..038ef44e3 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -57,10 +57,8 @@
org.teavm
- teavm-metaprogramming-api
+ teavm-metaprogramming-impl
${project.version}
- tests
- compile
junit
diff --git a/tests/src/test/java/org/teavm/metaprogramming/test/ProxyTest.java b/tests/src/test/java/org/teavm/metaprogramming/test/ProxyTest.java
index 1a4f3cd5a..715f8e1dd 100644
--- a/tests/src/test/java/org/teavm/metaprogramming/test/ProxyTest.java
+++ b/tests/src/test/java/org/teavm/metaprogramming/test/ProxyTest.java
@@ -22,7 +22,6 @@ import static org.teavm.metaprogramming.Metaprogramming.exit;
import static org.teavm.metaprogramming.Metaprogramming.proxy;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.teavm.classlib.java.lang.StringBuilderTest;
import org.teavm.junit.SkipJVM;
import org.teavm.junit.TeaVMTestRunner;
import org.teavm.metaprogramming.CompileTime;
diff --git a/tests/teavm-tests.iml b/tests/teavm-tests.iml
index 8322ddcbb..d808ac0cf 100644
--- a/tests/teavm-tests.iml
+++ b/tests/teavm-tests.iml
@@ -10,14 +10,6 @@
-
-
-
-
-
-
-
-
@@ -33,7 +25,7 @@
-
+
diff --git a/tools/core/teavm-tooling.iml b/tools/core/teavm-tooling.iml
index b2ca91d0f..cfd432be7 100644
--- a/tools/core/teavm-tooling.iml
+++ b/tools/core/teavm-tooling.iml
@@ -7,7 +7,7 @@
-
+
diff --git a/tools/junit/teavm-junit.iml b/tools/junit/teavm-junit.iml
index 00635f400..cbd5028f7 100644
--- a/tools/junit/teavm-junit.iml
+++ b/tools/junit/teavm-junit.iml
@@ -11,14 +11,6 @@
-
-
-
-
-
-
-
-