Support preserve-class option in CLI
@@ -32,6 +32,7 @@ import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -130,6 +131,12 @@ public final class TeaVMRunner {
.withDescription("Additional classpath that will be reloaded by TeaVM each time in wait mode")
.withLongOpt("classpath")
.create('p'));
+ options.addOption(OptionBuilder
+ .withArgName("class name")
+ .hasArgs()
+ .withDescription("Tell optimizer to not remove class, so that it can be found by Class.forName")
+ .withLongOpt("preserve-class")
+ .create());
options.addOption(OptionBuilder
.withLongOpt("wasm-version")
.withArgName("version")
@@ -167,6 +174,7 @@ public final class TeaVMRunner {
parseTargetOption();
parseOutputOptions();
parseDebugOptions();
+ parsePreserveClassOptions();
parseOptimizationOption();
parseIncrementalOptions();
parseJavaScriptOptions();
@@ -240,6 +248,12 @@ public final class TeaVMRunner {
}
}
+ private void parsePreserveClassOptions() {
+ if (commandLine.hasOption("preserve-class")) {
+ tool.getClassesToPreserve().addAll(Arrays.asList(commandLine.getOptionValues("preserve-class")));
+ }
+ }
+
private void parseOptimizationOption() {
if (commandLine.hasOption("O")) {
int level;
