From 85c686c72a492b04a2316d6e7d3cf355d807a863 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 9 Jan 2018 23:33:17 +0300 Subject: [PATCH] Remove outdated methodAliases build parameter Replace classAliases with classesToPreserve --- .gitignore | 1 + .../backend/javascript/JavaScriptTarget.java | 7 +- core/src/main/java/org/teavm/vm/TeaVM.java | 18 ++- .../java/org/teavm/vm/TeaVMEntryPoint.java | 2 +- .../org/teavm/vm/TeaVMTargetController.java | 5 +- pom.xml | 6 +- .../java/org/teavm/tooling/ClassAlias.java | 37 ------ .../java/org/teavm/tooling/MethodAlias.java | 64 ---------- .../java/org/teavm/tooling/TeaVMTool.java | 34 +----- .../eclipse/m2e/TeaVMProjectConfigurator.java | 18 ++- .../PreferencesBasedTeaVMProjectSettings.java | 26 ++-- .../java/org/teavm/eclipse/TeaVMProfile.java | 6 +- .../teavm/eclipse/TeaVMProjectBuilder.java | 8 +- .../teavm/eclipse/ui/TeaVMProfileDialog.java | 113 ++++++------------ .../org/teavm/maven/TeaVMCompileMojo.java | 14 +-- 15 files changed, 86 insertions(+), 273 deletions(-) delete mode 100644 tools/core/src/main/java/org/teavm/tooling/ClassAlias.java delete mode 100644 tools/core/src/main/java/org/teavm/tooling/MethodAlias.java diff --git a/.gitignore b/.gitignore index ce6c81986..d42521dff 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ target .factorypath .checkstyle .cache-main +.metadata # IntelliJ IDEA *.iml diff --git a/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java b/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java index 2f2421cf3..9753f7ca7 100644 --- a/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java +++ b/core/src/main/java/org/teavm/backend/javascript/JavaScriptTarget.java @@ -284,16 +284,13 @@ public class JavaScriptTarget implements TeaVMTarget, TeaVMJavaScriptHost { renderer.render(clsNodes); renderer.renderStringPool(); renderer.renderStringConstants(); - for (Map.Entry entry : controller.getEntryPoints().entrySet()) { + for (Map.Entry entry + : controller.getEntryPoints().entrySet()) { sourceWriter.append("var ").append(entry.getKey()).ws().append("=").ws(); MethodReference ref = entry.getValue().getReference(); sourceWriter.append(naming.getFullNameFor(ref)); sourceWriter.append(";").newLine(); } - for (Map.Entry entry : controller.getExportedClasses().entrySet()) { - sourceWriter.append("var ").append(entry.getKey()).ws().append("=").ws() - .appendClass(entry.getValue()).append(";").newLine(); - } for (RendererListener listener : rendererListeners) { listener.complete(); } diff --git a/core/src/main/java/org/teavm/vm/TeaVM.java b/core/src/main/java/org/teavm/vm/TeaVM.java index 531246598..5de0c0450 100644 --- a/core/src/main/java/org/teavm/vm/TeaVM.java +++ b/core/src/main/java/org/teavm/vm/TeaVM.java @@ -22,10 +22,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.ServiceLoader; +import java.util.Set; import java.util.stream.Collectors; import org.teavm.cache.NoCache; import org.teavm.common.ServiceRepository; @@ -109,8 +111,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository { private final ClassLoader classLoader; private final Map entryPoints = new HashMap<>(); private final Map readonlyEntryPoints = Collections.unmodifiableMap(entryPoints); - private final Map exportedClasses = new HashMap<>(); - private final Map readonlyExportedClasses = Collections.unmodifiableMap(exportedClasses); + private final Set preservedClasses = new HashSet<>(); + private final Set readonlyPreservedClasses = Collections.unmodifiableSet(preservedClasses); private final Map, Object> services = new HashMap<>(); private final Properties properties = new Properties(); private ProgramCache programCache; @@ -288,15 +290,11 @@ public class TeaVM implements TeaVMHost, ServiceRepository { return entryPoint; } - public void exportType(String name, String className) { - if (exportedClasses.containsKey(name)) { - throw new IllegalArgumentException("Class with public name `" + name + "' already defined for class " - + className); - } + public void preserveType(String className) { dependencyAnalyzer.defer(() -> { dependencyAnalyzer.linkClass(className, null).initClass(null); }); - exportedClasses.put(name, className); + preservedClasses.add(className); } /** @@ -675,8 +673,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository { } @Override - public Map getExportedClasses() { - return readonlyExportedClasses; + public Set getPreservedClasses() { + return readonlyPreservedClasses; } @Override diff --git a/core/src/main/java/org/teavm/vm/TeaVMEntryPoint.java b/core/src/main/java/org/teavm/vm/TeaVMEntryPoint.java index 6aa2fe3f8..df28d6907 100644 --- a/core/src/main/java/org/teavm/vm/TeaVMEntryPoint.java +++ b/core/src/main/java/org/teavm/vm/TeaVMEntryPoint.java @@ -38,7 +38,7 @@ import org.teavm.model.MethodReference; * Let's see how you achieve it:

* *
{@code
- *vm.exportType("JavaHashMap", "java.util.HashMap");
+ *vm.preserveType("JavaHashMap", "java.util.HashMap");
  *vm.entryPoint("initJavaHashMap", new MethodReference("java.util.HashMap",
  *        "", ValueType.VOID));
  *vm.entryPoint("putValueIntoJavaMap", new MethodReference(
diff --git a/core/src/main/java/org/teavm/vm/TeaVMTargetController.java b/core/src/main/java/org/teavm/vm/TeaVMTargetController.java
index 6e3ac4ee6..44f3d5825 100644
--- a/core/src/main/java/org/teavm/vm/TeaVMTargetController.java
+++ b/core/src/main/java/org/teavm/vm/TeaVMTargetController.java
@@ -17,6 +17,7 @@ package org.teavm.vm;
 
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 import org.teavm.common.ServiceRepository;
 import org.teavm.dependency.DependencyInfo;
 import org.teavm.diagnostics.Diagnostics;
@@ -41,7 +42,7 @@ public interface TeaVMTargetController {
 
     boolean isFriendlyToDebugger();
 
-    Map getEntryPoints();
+    Map getEntryPoints();
 
-    Map getExportedClasses();
+    Set getPreservedClasses();
 }
diff --git a/pom.xml b/pom.xml
index a3185993f..a29ddaf81 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,3 +1,4 @@
+
 
-
+-->
   4.0.0
 
   org.teavm
diff --git a/tools/core/src/main/java/org/teavm/tooling/ClassAlias.java b/tools/core/src/main/java/org/teavm/tooling/ClassAlias.java
deleted file mode 100644
index 4b55bda8e..000000000
--- a/tools/core/src/main/java/org/teavm/tooling/ClassAlias.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *  Copyright 2014 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.tooling;
-
-public class ClassAlias {
-    private String className;
-    private String alias;
-
-    public String getClassName() {
-        return className;
-    }
-
-    public void setClassName(String className) {
-        this.className = className;
-    }
-
-    public String getAlias() {
-        return alias;
-    }
-
-    public void setAlias(String alias) {
-        this.alias = alias;
-    }
-}
diff --git a/tools/core/src/main/java/org/teavm/tooling/MethodAlias.java b/tools/core/src/main/java/org/teavm/tooling/MethodAlias.java
deleted file mode 100644
index 9431bc69b..000000000
--- a/tools/core/src/main/java/org/teavm/tooling/MethodAlias.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- *  Copyright 2014 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.tooling;
-
-public class MethodAlias {
-    private String alias;
-    private String className;
-    private String methodName;
-    private String descriptor;
-    private String[] types;
-
-    public String getAlias() {
-        return alias;
-    }
-
-    public void setAlias(String alias) {
-        this.alias = alias;
-    }
-
-    public String getClassName() {
-        return className;
-    }
-
-    public void setClassName(String className) {
-        this.className = className;
-    }
-
-    public String getMethodName() {
-        return methodName;
-    }
-
-    public void setMethodName(String methodName) {
-        this.methodName = methodName;
-    }
-
-    public String getDescriptor() {
-        return descriptor;
-    }
-
-    public void setDescriptor(String descriptor) {
-        this.descriptor = descriptor;
-    }
-
-    public String[] getTypes() {
-        return types;
-    }
-
-    public void setTypes(String[] types) {
-        this.types = types;
-    }
-}
diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java
index 53f90c51f..2f3890e33 100644
--- a/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java
+++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java
@@ -61,7 +61,6 @@ import org.teavm.vm.BuildTarget;
 import org.teavm.vm.DirectoryBuildTarget;
 import org.teavm.vm.TeaVM;
 import org.teavm.vm.TeaVMBuilder;
-import org.teavm.vm.TeaVMEntryPoint;
 import org.teavm.vm.TeaVMOptimizationLevel;
 import org.teavm.vm.TeaVMProgressListener;
 import org.teavm.vm.TeaVMTarget;
@@ -81,8 +80,7 @@ public class TeaVMTool implements BaseTeaVMTool {
     private boolean incremental;
     private File cacheDirectory = new File("./teavm-cache");
     private List transformers = new ArrayList<>();
-    private List classAliases = new ArrayList<>();
-    private List methodAliases = new ArrayList<>();
+    private List classesToPreserve = new ArrayList<>();
     private TeaVMToolLog log = new EmptyTeaVMToolLog();
     private ClassLoader classLoader = TeaVMTool.class.getClassLoader();
     private DiskCachedClassHolderSource cachedClassSource;
@@ -197,12 +195,8 @@ public class TeaVMTool implements BaseTeaVMTool {
         return transformers;
     }
 
-    public List getClassAliases() {
-        return classAliases;
-    }
-
-    public List getMethodAliases() {
-        return methodAliases;
+    public List getClassesToPreserve() {
+        return classesToPreserve;
     }
 
     public TeaVMToolLog getLog() {
@@ -392,26 +386,8 @@ public class TeaVMTool implements BaseTeaVMTool {
                         .withArrayValue(1, "java.lang.String")
                         .async();
             }
-            for (ClassAlias alias : classAliases) {
-                vm.exportType(alias.getAlias(), alias.getClassName());
-            }
-            for (MethodAlias methodAlias : methodAliases) {
-                MethodReference ref = new MethodReference(methodAlias.getClassName(), methodAlias.getMethodName(),
-                        MethodDescriptor.parseSignature(methodAlias.getDescriptor()));
-                TeaVMEntryPoint entryPoint = vm.entryPoint(methodAlias.getAlias(), ref).async();
-                if (methodAlias.getTypes() != null) {
-                    for (int i = 0; i < methodAlias.getTypes().length; ++i) {
-                        String types = methodAlias.getTypes()[i];
-                        if (types != null) {
-                            for (String type : types.split(" +")) {
-                                type = type.trim();
-                                if (!type.isEmpty()) {
-                                    entryPoint.withValue(i, type);
-                                }
-                            }
-                        }
-                    }
-                }
+            for (String className : classesToPreserve) {
+                vm.preserveType(className);
             }
             targetDirectory.mkdirs();
 
diff --git a/tools/eclipse/m2e-plugin/src/main/java/org/teavm/eclipse/m2e/TeaVMProjectConfigurator.java b/tools/eclipse/m2e-plugin/src/main/java/org/teavm/eclipse/m2e/TeaVMProjectConfigurator.java
index 5a829e85b..e3bfd14e8 100644
--- a/tools/eclipse/m2e-plugin/src/main/java/org/teavm/eclipse/m2e/TeaVMProjectConfigurator.java
+++ b/tools/eclipse/m2e-plugin/src/main/java/org/teavm/eclipse/m2e/TeaVMProjectConfigurator.java
@@ -144,23 +144,21 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
         profile.setTransformers(transformers != null ? transformers : new String[0]);
         monitor.worked(10);
 
-        profile.setClassAliases(readClassAliases(execution));
+        profile.setClassesToPreserve(readClassesToPreserve(execution));
         monitor.worked(10);
 
         monitor.done();
     }
 
-    private Map readClassAliases(MojoExecution execution) {
-        Map aliases = new HashMap<>();
-        Xpp3Dom aliasesElem = execution.getConfiguration().getChild("classAliases");
-        if (aliasesElem != null) {
-            for (Xpp3Dom item : aliasesElem.getChildren()) {
-                String className = item.getChild("className").getValue();
-                String alias = item.getChild("alias").getValue();
-                aliases.put(className, alias);
+    private Set readClassesToPreserve(MojoExecution execution) {
+        Set classes = new HashSet<>();
+        Xpp3Dom classesElem = execution.getConfiguration().getChild("classesToPreserve");
+        if (classesElem != null) {
+            for (Xpp3Dom item : classesElem.getChildren()) {
+                classes.add(item.getValue());
             }
         }
-        return aliases;
+        return classes;
     }
 
     private String getProjectBuildDirectory() throws CoreException {
diff --git a/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java b/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java
index ca017d344..4b1f67464 100644
--- a/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java
+++ b/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/PreferencesBasedTeaVMProjectSettings.java
@@ -16,6 +16,8 @@
 package org.teavm.eclipse;
 
 import java.util.*;
+import java.util.stream.Collectors;
+
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ProjectScope;
 import org.eclipse.core.runtime.CoreException;
@@ -163,7 +165,7 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
         private boolean sourceFilesCopied;
         private Properties properties = new Properties();
         private String[] transformers = new String[0];
-        private Map classAliases = new HashMap<>();
+        private Set classesToPreserve = new HashSet<>();
         private String externalToolId = "";
 
         @Override
@@ -306,13 +308,14 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
         }
 
         @Override
-        public Map getClassAliases() {
-            return new HashMap<>(classAliases);
+        public Set getClassesToPreserve() {
+            return classesToPreserve;
         }
 
         @Override
-        public void setClassAliases(Map classAliases) {
-            this.classAliases = new HashMap<>(classAliases);
+        public void setClassesToPreserve(Set classesToPreserve) {
+        	this.classesToPreserve.clear();
+        	this.classesToPreserve.addAll(classesToPreserve);
         }
 
         @Override
@@ -357,11 +360,7 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
             Preferences transformersPrefs = preferences.node(TRANSFORMERS);
             transformersPrefs.sync();
             transformers = transformersPrefs.keys();
-            Preferences classesPrefs = preferences.node(CLASSES);
-            classesPrefs.sync();
-            for (String key : classesPrefs.keys()) {
-                classAliases.put(key, classesPrefs.get(key, "_"));
-            }
+            classesToPreserve.addAll(Arrays.asList(preferences.get(CLASSES, "").split(" ")));
             externalToolId = preferences.get(EXTERNAL_TOOL_ID, "");
         }
 
@@ -390,12 +389,7 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
                 transformersPrefs.put(transformer, "");
             }
             transformersPrefs.flush();
-            Preferences classesPrefs = preferences.node(CLASSES);
-            classesPrefs.clear();
-            for (String key : classAliases.keySet()) {
-                classesPrefs.put(key, classAliases.get(key));
-            }
-            classesPrefs.flush();
+            preferences.put(CLASSES, classesToPreserve.stream().collect(Collectors.joining(" ")));
             preferences.put(EXTERNAL_TOOL_ID, externalToolId);
             preferences.flush();
         }
diff --git a/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/TeaVMProfile.java b/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/TeaVMProfile.java
index c190b85f7..0afe292fd 100644
--- a/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/TeaVMProfile.java
+++ b/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/TeaVMProfile.java
@@ -15,8 +15,8 @@
  */
 package org.teavm.eclipse;
 
-import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 
 public interface TeaVMProfile {
     String getName();
@@ -75,9 +75,9 @@ public interface TeaVMProfile {
 
     void setTransformers(String[] transformers);
 
-    Map getClassAliases();
+    Set getClassesToPreserve();
 
-    void setClassAliases(Map classAliases);
+    void setClassesToPreserve(Set classesToPreserve);
 
     String getExternalToolId();
 
diff --git a/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/TeaVMProjectBuilder.java b/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/TeaVMProjectBuilder.java
index d9ab8c4c3..8b8fa2780 100644
--- a/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/TeaVMProjectBuilder.java
+++ b/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/TeaVMProjectBuilder.java
@@ -70,7 +70,6 @@ import org.teavm.model.FieldReference;
 import org.teavm.model.MethodReference;
 import org.teavm.model.TextLocation;
 import org.teavm.model.ValueType;
-import org.teavm.tooling.ClassAlias;
 import org.teavm.tooling.RuntimeCopyOperation;
 import org.teavm.tooling.TeaVMTool;
 import org.teavm.tooling.TeaVMToolException;
@@ -163,12 +162,7 @@ public class TeaVMProjectBuilder extends IncrementalProjectBuilder {
         for (ClassHolderTransformer transformer : instantiateTransformers(profile, classLoader)) {
             tool.getTransformers().add(transformer);
         }
-        for (Map.Entry entry : profile.getClassAliases().entrySet()) {
-            ClassAlias classAlias = new ClassAlias();
-            classAlias.setClassName(entry.getKey());
-            classAlias.setAlias(entry.getValue());
-            tool.getClassAliases().add(classAlias);
-        }
+        tool.getClassesToPreserve().addAll(profile.getClassesToPreserve());
         for (SourceFileProvider provider : sourceProviders) {
             tool.addSourceFileProvider(provider);
         }
diff --git a/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/ui/TeaVMProfileDialog.java b/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/ui/TeaVMProfileDialog.java
index f497d985e..a788b5175 100644
--- a/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/ui/TeaVMProfileDialog.java
+++ b/tools/eclipse/plugin/src/main/java/org/teavm/eclipse/ui/TeaVMProfileDialog.java
@@ -15,8 +15,12 @@
  */
 package org.teavm.eclipse.ui;
 
-import java.util.*;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
 import org.eclipse.core.databinding.observable.list.WritableList;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -30,14 +34,32 @@ import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TextCellEditor;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.ScrolledComposite;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
 import org.eclipse.ui.model.WorkbenchContentProvider;
 import org.eclipse.ui.model.WorkbenchLabelProvider;
@@ -70,10 +92,9 @@ public class TeaVMProfileDialog extends Dialog {
     private Button addPropertyButton;
     private Button deletePropertyButton;
     private WritableList propertyList = new WritableList();
-    private TableViewer classAliasesTableViewer;
+    private org.eclipse.swt.widgets.List classAliasesTableViewer;
     private Button addClassAliasButton;
     private Button removeClassAliasButton;
-    private WritableList classAliases = new WritableList();
     private org.eclipse.swt.widgets.List transformersList;
     private Button addTransformerButton;
     private Button removeTransformerButton;
@@ -290,46 +311,8 @@ public class TeaVMProfileDialog extends Dialog {
 
     private void createClassesGroup(Composite parent) {
         Group group = createGroup(parent, "Class aliases", 2, true);
-        classAliasesTableViewer = new TableViewer(group, SWT.BORDER | SWT.V_SCROLL);
-        classAliasesTableViewer.getTable().setLinesVisible(true);
-        classAliasesTableViewer.getTable().setHeaderVisible(true);
-        classAliasesTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
-        classAliasesTableViewer.setContentProvider(new ObservableListContentProvider());
-        classAliasesTableViewer.setInput(classAliases);
-
-        TableViewerColumn classNameColumn = new TableViewerColumn(classAliasesTableViewer, SWT.LEFT);
-        classNameColumn.getColumn().setWidth(200);
-        classNameColumn.getColumn().setText("Class");
-        classNameColumn.setLabelProvider(new ColumnLabelProvider() {
-            @Override public String getText(Object element) {
-                ClassAliasRow item = (ClassAliasRow)element;
-                return item.className;
-            }
-        });
-
-        TableViewerColumn valueColumn = new TableViewerColumn(classAliasesTableViewer, SWT.LEFT);
-        valueColumn.getColumn().setWidth(200);
-        valueColumn.getColumn().setText("Alias");
-        valueColumn.setLabelProvider(new ColumnLabelProvider() {
-            @Override public String getText(Object element) {
-                ClassAliasRow item = (ClassAliasRow)element;
-                return item.alias;
-            }
-        });
-        valueColumn.setEditingSupport(new EditingSupport(valueColumn.getViewer()) {
-            private TextCellEditor editor = new TextCellEditor(classAliasesTableViewer.getTable());
-            @Override protected Object getValue(Object element) {
-                ClassAliasRow item = (ClassAliasRow)element;
-                return item.alias;
-            }
-            @Override protected void setValue(Object element, Object value) {
-                ClassAliasRow item = (ClassAliasRow)element;
-                item.alias = (String)value;
-                getViewer().update(element, null);
-            }
-            @Override protected boolean canEdit(Object element) { return true; }
-            @Override protected CellEditor getCellEditor(Object element) { return editor; }
-        });
+        classAliasesTableViewer = new org.eclipse.swt.widgets.List(group, SWT.BORDER | SWT.SINGLE);
+        classAliasesTableViewer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
 
         addClassAliasButton = new Button(group, SWT.PUSH);
         addClassAliasButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
@@ -346,11 +329,6 @@ public class TeaVMProfileDialog extends Dialog {
         });
     }
 
-    static class ClassAliasRow {
-        String className;
-        String alias;
-    }
-
     private void createTransformersGroup(Composite parent) {
         Group group = createGroup(parent, "TeaVM bytecode transformers", 2, true);
         transformersList = new org.eclipse.swt.widgets.List(group, SWT.SINGLE | SWT.BORDER);
@@ -603,31 +581,22 @@ public class TeaVMProfileDialog extends Dialog {
             Object[] result = selectionDialog.getResult();
             if (result.length > 0) {
                 IType type = (IType)result[0];
-                for (int i = 0; i < classAliases.size(); ++i) {
-                    ClassAliasRow row = (ClassAliasRow)classAliases.get(i);
-                    if (row.className.equals(type.getFullyQualifiedName())) {
-                        return;
-                    }
-                }
-                ClassAliasRow row = new ClassAliasRow();
-                row.alias = "_";
-                row.className = type.getFullyQualifiedName();
-                classAliases.add(row);
+                classAliasesTableViewer.add(type.getFullyQualifiedName());
             }
         }
     }
 
     private void removeClass() {
-        Table table = classAliasesTableViewer.getTable();
-        if (table.getSelectionCount() != 1) {
+        if (classAliasesTableViewer.getSelectionCount() != 1) {
             return;
         }
+        String className = classAliasesTableViewer.getItem(classAliasesTableViewer.getSelectionIndex());
         boolean confirmed = MessageDialog.openConfirm(getShell(), "Removal confirmation",
-                "Are you sure to delete the " + table.getSelection()[0].getText(0) + " class?");
+                "Are you sure to delete the " + className + " class?");
         if (!confirmed) {
             return;
         }
-        classAliases.remove(table.getSelectionIndex());
+        classAliasesTableViewer.remove(classAliasesTableViewer.getSelectionIndex());
     }
 
     @Override
@@ -682,11 +651,8 @@ public class TeaVMProfileDialog extends Dialog {
         }
         updateCacheFieldsEnabled();
         transformersList.setItems(profile.getTransformers());
-        for (Map.Entry entry : profile.getClassAliases().entrySet()) {
-            ClassAliasRow row = new ClassAliasRow();
-            row.className = entry.getKey();
-            row.alias = entry.getValue();
-            classAliases.add(row);
+        for (String className : profile.getClassesToPreserve()) {
+            classAliasesTableViewer.add(className);
         }
         for (Control control : tabFolder.getTabList()) {
             if (control instanceof Composite) {
@@ -720,12 +686,11 @@ public class TeaVMProfileDialog extends Dialog {
         }
         profile.setProperties(properties);
         profile.setTransformers(transformersList.getItems());
-        Map classAliasMap = new HashMap<>();
-        for (int i = 0; i < classAliases.size(); ++i) {
-            ClassAliasRow row = (ClassAliasRow)classAliases.get(i);
-            classAliasMap.put(row.className, row.alias);
+        Set classesToPreserve = new HashSet<>();
+        for (int i = 0; i < classAliasesTableViewer.getItemCount(); ++i) {
+            classesToPreserve.add(classAliasesTableViewer.getItem(i));
         }
-        profile.setClassAliases(classAliasMap);
+        profile.setClassesToPreserve(classesToPreserve);
         return true;
     }
 }
diff --git a/tools/maven/plugin/src/main/java/org/teavm/maven/TeaVMCompileMojo.java b/tools/maven/plugin/src/main/java/org/teavm/maven/TeaVMCompileMojo.java
index c440a4869..b72349275 100644
--- a/tools/maven/plugin/src/main/java/org/teavm/maven/TeaVMCompileMojo.java
+++ b/tools/maven/plugin/src/main/java/org/teavm/maven/TeaVMCompileMojo.java
@@ -25,8 +25,6 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.teavm.backend.wasm.render.WasmBinaryVersion;
-import org.teavm.tooling.ClassAlias;
-import org.teavm.tooling.MethodAlias;
 import org.teavm.tooling.RuntimeCopyOperation;
 import org.teavm.tooling.TeaVMTargetType;
 import org.teavm.tooling.TeaVMTool;
@@ -52,10 +50,7 @@ public class TeaVMCompileMojo extends AbstractTeaVMMojo {
     private String mainClass;
 
     @Parameter
-    private ClassAlias[] classAliases;
-
-    @Parameter
-    private MethodAlias[] methodAliases;
+    private String[] classesToPreserve;
 
     @Parameter
     private boolean stopOnErrors = true;
@@ -94,11 +89,8 @@ public class TeaVMCompileMojo extends AbstractTeaVMMojo {
                 tool.setTargetFileName(targetFileName);
             }
             tool.setOptimizationLevel(optimizationLevel);
-            if (classAliases != null) {
-                tool.getClassAliases().addAll(Arrays.asList(classAliases));
-            }
-            if (methodAliases != null) {
-                tool.getMethodAliases().addAll(Arrays.asList(methodAliases));
+            if (classesToPreserve != null) {
+                tool.getClassesToPreserve().addAll(Arrays.asList(classesToPreserve));
             }
             tool.setCacheDirectory(cacheDirectory);
             tool.setTargetType(targetType);