From 1a8ec9e809639a8b11e5ba675f4939f8884b6f29 Mon Sep 17 00:00:00 2001
From: katherine-hough <32645020+katherine-hough@users.noreply.github.com>
Date: Sun, 26 Nov 2023 13:10:48 -0500
Subject: [PATCH] * Started working on Jar driver
---
Phosphor/pom.xml | 36 ++-----
.../columbia/cs/psl/phosphor/OptionsUtil.java | 88 -----------------
.../cs/psl/phosphor/PhosphorOption.java | 95 +++++++++++++++----
.../src/main/resources/META-INF/MANIFEST.MF | 5 -
.../swe/phosphor/instrument/Instrumenter.java | 46 ++++-----
.../instrument/PhosphorInstrumentation.java | 23 ++++-
.../instrument/PhosphorInstrumenter.java | 25 +++--
pom.xml | 2 +-
8 files changed, 144 insertions(+), 176 deletions(-)
delete mode 100644 Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/OptionsUtil.java
delete mode 100644 Phosphor/src/main/resources/META-INF/MANIFEST.MF
diff --git a/Phosphor/pom.xml b/Phosphor/pom.xml
index 9d0ef5706..db28b1a93 100644
--- a/Phosphor/pom.xml
+++ b/Phosphor/pom.xml
@@ -17,37 +17,19 @@
maven-jar-plugin
- src/main/resources/META-INF/MANIFEST.MF
+
+
+ edu.columbia.cs.psl.phosphor.Java8PreMain
+
+ true
+
-
- java/
- sun/
-
+ true
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 3.1.1
-
- none
- true
-
- sun.*:java.*
-
-
-
- attach-javadoc
-
- jar
-
-
-
-
org.codehaus.mojo
exec-maven-plugin
- 1.6.0
generate-stubs
@@ -95,7 +77,8 @@
- edu/columbia/cs/psl/phosphor/org/objectweb/asm/tree/FrameNode.class
+
+ edu/columbia/cs/psl/phosphor/org/objectweb/asm/tree/FrameNode.class
@@ -109,6 +92,7 @@
+ true
true
true
diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/OptionsUtil.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/OptionsUtil.java
deleted file mode 100644
index 0bd356470..000000000
--- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/OptionsUtil.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package edu.columbia.cs.psl.phosphor;
-
-import edu.columbia.cs.psl.phosphor.struct.SinglyLinkedList;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import java.util.*;
-
-public class OptionsUtil {
- /**
- * Creates a standardized copy of the specified properties where each Phosphor option without an argument is mapped
- * to either true or not present in the properties, each Phosphor option with an argument is either mapped to a
- * non-null, non-empty string or not present in properties, and no other keys are present in the properties.
- *
- * @param properties properties to be standardized
- * @return a standardized copy of properties
- */
- private static Properties standardize(Properties properties) {
- Properties result = new Properties();
- Map phosphorOptionMap = createOptionMap();
- for (String key : properties.stringPropertyNames()) {
- String value = properties.getProperty(key);
- if (phosphorOptionMap.containsKey(key)) {
- Option option = phosphorOptionMap.get(key);
- if (option.hasArg() && value != null && !value.isEmpty()) {
- result.setProperty(option.getOpt(), value);
- } else if (!option.hasArg() && (value == null || value.isEmpty() || "true".equalsIgnoreCase(value))) {
- result.setProperty(option.getOpt(), "true");
- }
- } else {
- throw new IllegalArgumentException("Unknown option: " + key);
- }
- }
- return result;
- }
-
- /**
- * @return a mapping from the names of configuration options available in Phosphor to an instance of
- * org.apache.commons.cli.Option that represents that configuration option
- */
- private static Map createOptionMap() {
- Map map = new HashMap<>();
- Options options = PhosphorOption.createOptions(false);
- for (Option option : options.getOptions()) {
- map.put(option.getOpt(), option);
- if (option.hasLongOpt()) {
- map.put(option.getLongOpt(), option);
- }
- }
- return map;
- }
-
- public static String[] createPhosphorMainArguments(Properties properties) {
- properties = standardize(properties);
- SinglyLinkedList arguments = new SinglyLinkedList<>();
- Set propNames = properties.stringPropertyNames();
- for (String propName : propNames) {
- arguments.addLast("-" + propName);
- if (!"true".equals(properties.getProperty(propName))) {
- arguments.addLast(properties.getProperty(propName));
- }
- }
- arguments.addLast("temp/");
- arguments.addLast("temp2/");
- return arguments.toArray(new String[0]);
- }
-
- public static Set> getConfigurationClasses(Properties properties) {
- Set> classes = new HashSet<>();
- Options options = PhosphorOption.createOptions(false);
- for (Option option : options.getOptions()) {
- if (option.getType().equals(Class.class)) {
- String key = option.getOpt();
- if (properties.containsKey(key)) {
- try {
- Class> clazz = Class.forName(properties.getProperty(key));
- classes.add(clazz);
- } catch (ReflectiveOperationException e) {
- String message =
- String.format("Failed to create %s class: %s", key, properties.getProperty(key));
- throw new IllegalArgumentException(message, e);
- }
- }
- }
- }
- return classes;
- }
-}
diff --git a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorOption.java b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorOption.java
index 3087b1809..522fd76fa 100644
--- a/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorOption.java
+++ b/Phosphor/src/main/java/edu/columbia/cs/psl/phosphor/PhosphorOption.java
@@ -7,9 +7,10 @@
import org.apache.commons.cli.*;
import org.objectweb.asm.ClassVisitor;
+import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.util.EnumMap;
+import java.util.*;
public enum PhosphorOption {
@@ -369,42 +370,94 @@ public static Options createOptions(boolean forRuntimeInst) {
}
}
}
- for(OptionGroup group : groupMap.values()) {
+ for (OptionGroup group : groupMap.values()) {
options.addOptionGroup(group);
}
return options;
}
- public static CommandLine configure(boolean forRuntimeInst, String[] args) {
- CommandLineParser parser = new DefaultParser();
- Options options = createOptions(forRuntimeInst);
+ public static CommandLine configure(boolean isRuntime, String[] args) {
+ String commandSynopsis = "java -jar phosphor.jar [OPTIONS]