From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master
Reformatted java/runjava and java/tests
Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
Message-Id: <1476420296-4125-1-git-send-email-jwkozac...@gmail.com>
---
diff --git a/java/runjava/src/main/java/io/osv/GCInfo.java
b/java/runjava/src/main/java/io/osv/GCInfo.java
--- a/java/runjava/src/main/java/io/osv/GCInfo.java
+++ b/java/runjava/src/main/java/io/osv/GCInfo.java
@@ -8,13 +8,11 @@
/**
- *
* A helper class that holds Garbage collection information
- *
*/
public class GCInfo {
- long count;
- long time;
- String name;
- String[] pools;
+ long count;
+ long time;
+ String name;
+ String[] pools;
}
diff --git a/java/runjava/src/main/java/io/osv/JavaInfo.java
b/java/runjava/src/main/java/io/osv/JavaInfo.java
--- a/java/runjava/src/main/java/io/osv/JavaInfo.java
+++ b/java/runjava/src/main/java/io/osv/JavaInfo.java
@@ -2,6 +2,7 @@
import io.osv.util.json.ArrayBuilder;
import io.osv.util.json.JsonGenerator;
+
import java.lang.management.GarbageCollectorMXBean;
import java.util.List;
import java.util.Set;
@@ -25,150 +26,143 @@
*/
public class JavaInfo {
- /**
- * Get an Mbean description and data
- *
- * @param mbeanName
- * the MBean name
- * @return a string in a JSON format representative of the MBean
- * @throws MalformedObjectNameException
- * @throws ReflectionException
- * @throws InstanceNotFoundException
- * @throws IntrospectionException
- * @throws MBeanException
- * @throws AttributeNotFoundException
- */
- public static String getMbean(String mbeanName)
- throws MalformedObjectNameException,
IntrospectionException,
- InstanceNotFoundException, ReflectionException,
- AttributeNotFoundException, MBeanException {
- javax.management.MBeanServer mbeanServer =
java.lang.management.ManagementFactory
- .getPlatformMBeanServer();
- ObjectName objName = new ObjectName(mbeanName);
- MBeanInfo res = mbeanServer.getMBeanInfo(objName);
+ /**
+ * Get an Mbean description and data
+ *
+ * @param mbeanName the MBean name
+ * @return a string in a JSON format representative of the MBean
+ * @throws MalformedObjectNameException
+ * @throws ReflectionException
+ * @throws InstanceNotFoundException
+ * @throws IntrospectionException
+ * @throws MBeanException
+ * @throws AttributeNotFoundException
+ */
+ public static String getMbean(String mbeanName)
+ throws MalformedObjectNameException, IntrospectionException,
+ InstanceNotFoundException, ReflectionException,
+ AttributeNotFoundException, MBeanException {
+ javax.management.MBeanServer mbeanServer =
java.lang.management.ManagementFactory
+ .getPlatformMBeanServer();
+ ObjectName objName = new ObjectName(mbeanName);
+ MBeanInfo res = mbeanServer.getMBeanInfo(objName);
- MBeanAttributeInfo[] att = res.getAttributes();
- ArrayBuilder sb = new ArrayBuilder();
- for (int i = 0; i < att.length; i++) {
- try {
- sb.append(JsonGenerator.attrToString(att[i],
objName,
- mbeanServer));
- } catch (javax.management.RuntimeMBeanException e) {
- // some of the attribute can throw
UnsupportedOperationException
- // even if
- // they have read permission
- }
- }
- return sb.toString();
- }
+ MBeanAttributeInfo[] att = res.getAttributes();
+ ArrayBuilder sb = new ArrayBuilder();
+ for (int i = 0; i < att.length; i++) {
+ try {
+ sb.append(JsonGenerator.attrToString(att[i], objName,
+ mbeanServer));
+ } catch (javax.management.RuntimeMBeanException e) {
+ // some of the attribute can throw
UnsupportedOperationException
+ // even if
+ // they have read permission
+ }
+ }
+ return sb.toString();
+ }
- /**
- * Set an MBean attribute to a new value
- *
- * @param mbeanName
- * the MBean name
- * @param attribute
- * the attribute name, the attribute use an xpath syntax to
- * define the full path into the attribute
- * @param value
- * the value to set
- * @throws MalformedObjectNameException
- * @throws ReflectionException
- * @throws MBeanException
- * @throws InstanceNotFoundException
- * @throws AttributeNotFoundException
- * @throws InvalidAttributeValueException
- */
- public static void setMbean(String mbeanName, String attribute, String
value)
- throws MalformedObjectNameException,
AttributeNotFoundException,
- InstanceNotFoundException, MBeanException,
ReflectionException,
- InvalidAttributeValueException {
- javax.management.MBeanServer mbeanServer =
java.lang.management.ManagementFactory
- .getPlatformMBeanServer();
- ObjectName objName = new ObjectName(mbeanName);
- Object attr = mbeanServer.getAttribute(objName, attribute);
- Object valueObject = getUpdatedAttribute(attr, value);
- if (valueObject != null) {
- mbeanServer.setAttribute(objName, new
Attribute(attribute,
- valueObject));
- }
- }
+ /**
+ * Set an MBean attribute to a new value
+ *
+ * @param mbeanName the MBean name
+ * @param attribute the attribute name, the attribute use an xpath
syntax to
+ * define the full path into the attribute
+ * @param value the value to set
+ * @throws MalformedObjectNameException
+ * @throws ReflectionException
+ * @throws MBeanException
+ * @throws InstanceNotFoundException
+ * @throws AttributeNotFoundException
+ * @throws InvalidAttributeValueException
+ */
+ public static void setMbean(String mbeanName, String attribute, String
value)
+ throws MalformedObjectNameException,
AttributeNotFoundException,
+ InstanceNotFoundException, MBeanException, ReflectionException,
+ InvalidAttributeValueException {
+ javax.management.MBeanServer mbeanServer =
java.lang.management.ManagementFactory
+ .getPlatformMBeanServer();
+ ObjectName objName = new ObjectName(mbeanName);
+ Object attr = mbeanServer.getAttribute(objName, attribute);
+ Object valueObject = getUpdatedAttribute(attr, value);
+ if (valueObject != null) {
+ mbeanServer.setAttribute(objName, new Attribute(attribute,
+ valueObject));
+ }
+ }
- /**
- * A helper method to get an updated attribute from an existing one. It
uses
- * the original attribute determine the type the value should be mapped
to.
- *
- * @param attr
- * the original attribute
- * @param value
- * the new value
- * @return the new attribute
- */
- private static Object getUpdatedAttribute(Object attr, String value) {
- if (attr instanceof Long) {
- return Long.parseLong(value);
- }
- if (attr instanceof String) {
- return value;
- }
- if (attr instanceof Boolean) {
- return Boolean.valueOf(value);
- }
- if (attr instanceof Integer) {
- return Integer.parseInt(value);
- }
- return null;
- }
+ /**
+ * A helper method to get an updated attribute from an existing one.
It uses
+ * the original attribute determine the type the value should be
mapped to.
+ *
+ * @param attr the original attribute
+ * @param value the new value
+ * @return the new attribute
+ */
+ private static Object getUpdatedAttribute(Object attr, String value) {
+ if (attr instanceof Long) {
+ return Long.parseLong(value);
+ }
+ if (attr instanceof String) {
+ return value;
+ }
+ if (attr instanceof Boolean) {
+ return Boolean.valueOf(value);
+ }
+ if (attr instanceof Integer) {
+ return Integer.parseInt(value);
+ }
+ return null;
+ }
- /**
- * Get a list of all available MBean names.
- *
- * @return an array of string with all the mbeanServer names
- */
- public static String[] getAllMbean() {
- javax.management.MBeanServer mbeanServer =
java.lang.management.ManagementFactory
- .getPlatformMBeanServer();
- Set<ObjectName> instances = mbeanServer.queryNames(null, null);
- String[] res = new String[instances.size()];
- int i = 0;
- for (ObjectName obj : instances) {
- res[i++] = obj.getCanonicalName();
- }
+ /**
+ * Get a list of all available MBean names.
+ *
+ * @return an array of string with all the mbeanServer names
+ */
+ public static String[] getAllMbean() {
+ javax.management.MBeanServer mbeanServer =
java.lang.management.ManagementFactory
+ .getPlatformMBeanServer();
+ Set<ObjectName> instances = mbeanServer.queryNames(null, null);
+ String[] res = new String[instances.size()];
+ int i = 0;
+ for (ObjectName obj : instances) {
+ res[i++] = obj.getCanonicalName();
+ }
- return res;
- }
+ return res;
+ }
- /**
- * Get garbage collector information
- *
- * @return an array of GCInfo object
- */
- public static GCInfo[] getAllGC() {
- List<GarbageCollectorMXBean> gcCollection =
java.lang.management.ManagementFactory
- .getGarbageCollectorMXBeans();
- GCInfo[] res = new GCInfo[gcCollection.size()];
- int i = 0;
- for (GarbageCollectorMXBean gc : gcCollection) {
- GCInfo info = new GCInfo();
- info.count = gc.getCollectionCount();
- info.name = gc.getName();
- info.time = gc.getCollectionTime();
- info.pools = gc.getMemoryPoolNames();
- res[i++] = info;
+ /**
+ * Get garbage collector information
+ *
+ * @return an array of GCInfo object
+ */
+ public static GCInfo[] getAllGC() {
+ List<GarbageCollectorMXBean> gcCollection =
java.lang.management.ManagementFactory
+ .getGarbageCollectorMXBeans();
+ GCInfo[] res = new GCInfo[gcCollection.size()];
+ int i = 0;
+ for (GarbageCollectorMXBean gc : gcCollection) {
+ GCInfo info = new GCInfo();
+ info.count = gc.getCollectionCount();
+ info.name = gc.getName();
+ info.time = gc.getCollectionTime();
+ info.pools = gc.getMemoryPoolNames();
+ res[i++] = info;
- }
- return res;
- }
+ }
+ return res;
+ }
- /**
- * Get a system property
- *
- * @param str
- * a system property name
- * @return the system property value
- */
- public static String getProperty(String str) {
- return System.getProperty(str);
- }
+ /**
+ * Get a system property
+ *
+ * @param str a system property name
+ * @return the system property value
+ */
+ public static String getProperty(String str) {
+ return System.getProperty(str);
+ }
}
diff --git a/java/runjava/src/main/java/io/osv/Jvm.java
b/java/runjava/src/main/java/io/osv/Jvm.java
--- a/java/runjava/src/main/java/io/osv/Jvm.java
+++ b/java/runjava/src/main/java/io/osv/Jvm.java
@@ -90,7 +90,7 @@ private T runClass(String mainClass, String[] args,
Iterable<String> classpath,
}
protected abstract T run(ClassLoader classLoader, final String
classpath, final String mainClass,
- final String[] args, final Properties properties);
+ final String[] args, final Properties
properties);
protected abstract ClassLoader getParentClassLoader();
diff --git
a/java/runjava/src/main/java/io/osv/MainClassNotFoundException.java
b/java/runjava/src/main/java/io/osv/MainClassNotFoundException.java
--- a/java/runjava/src/main/java/io/osv/MainClassNotFoundException.java
+++ b/java/runjava/src/main/java/io/osv/MainClassNotFoundException.java
@@ -12,7 +12,7 @@
private String mainClassName;
public MainClassNotFoundException(String mainClass) {
- mainClassName = mainClass;
+ mainClassName = mainClass;
}
public String getClassName() {
diff --git a/java/runjava/src/main/java/io/osv/RunJvmAppHelper.java
b/java/runjava/src/main/java/io/osv/RunJvmAppHelper.java
--- a/java/runjava/src/main/java/io/osv/RunJvmAppHelper.java
+++ b/java/runjava/src/main/java/io/osv/RunJvmAppHelper.java
@@ -9,36 +9,36 @@
*/
public class RunJvmAppHelper {
- public interface JvmFactory {
- Jvm getJvm();
- }
+ public interface JvmFactory {
+ Jvm getJvm();
+ }
- static public void runSync(JvmFactory jvmFactory, String[] args) {
+ static public void runSync(JvmFactory jvmFactory, String[] args) {
- if (args.length > 0 && args[0].equals("-version")) {
- System.err.println("java version \"" +
- System.getProperty("java.version") + "\"");
- System.err.println(System.getProperty("java.runtime.name") +
- " (" + System.getProperty("java.runtime.version") +
- ")");
- System.err.println(System.getProperty("java.vm.name") +
- " (build " + System.getProperty("java.vm.version") +
- ", " + System.getProperty("java.vm.info") + ")");
- return;
- }
+ if (args.length > 0 && args[0].equals("-version")) {
+ System.err.println("java version \"" +
+ System.getProperty("java.version") + "\"");
+ System.err.println(System.getProperty("java.runtime.name") +
+ " (" + System.getProperty("java.runtime.version") +
+ ")");
+ System.err.println(System.getProperty("java.vm.name") +
+ " (build " + System.getProperty("java.vm.version") +
+ ", " + System.getProperty("java.vm.info") + ")");
+ return;
+ }
- try {
- jvmFactory.getJvm().runSync(args);
- } catch (IllegalArgumentException ex) {
- System.err.println("RunJava: " + ex.getMessage());
- } catch (AppThreadTerminatedWithUncaughtException ex) {
- if (ex.getCause() instanceof MainClassNotFoundException) {
- System.err.println("Error: Could not find or load main
class " + ((MainClassNotFoundException) ex.getCause()).getClassName());
- } else {
- ex.printStackTrace();
- }
- } catch (Throwable ex) {
- ex.printStackTrace();
- }
- }
+ try {
+ jvmFactory.getJvm().runSync(args);
+ } catch (IllegalArgumentException ex) {
+ System.err.println("RunJava: " + ex.getMessage());
+ } catch (AppThreadTerminatedWithUncaughtException ex) {
+ if (ex.getCause() instanceof MainClassNotFoundException) {
+ System.err.println("Error: Could not find or load main
class " + ((MainClassNotFoundException) ex.getCause()).getClassName());
+ } else {
+ ex.printStackTrace();
+ }
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ }
+ }
}
diff --git a/java/runjava/src/main/java/io/osv/isolated/IsolatedJvm.java
b/java/runjava/src/main/java/io/osv/isolated/IsolatedJvm.java
--- a/java/runjava/src/main/java/io/osv/isolated/IsolatedJvm.java
+++ b/java/runjava/src/main/java/io/osv/isolated/IsolatedJvm.java
@@ -89,7 +89,7 @@ public Context getContext() {
}
protected Context run(ClassLoader classLoader, final String classpath,
final String mainClass,
- final String[] args, final Properties properties) {
+ final String[] args, final Properties
properties) {
Properties contextProperties = new Properties();
contextProperties.putAll(commonSystemProperties);
contextProperties.putAll(properties);
diff --git a/java/runjava/src/main/java/io/osv/isolated/MultiJarLoader.java
b/java/runjava/src/main/java/io/osv/isolated/MultiJarLoader.java
--- a/java/runjava/src/main/java/io/osv/isolated/MultiJarLoader.java
+++ b/java/runjava/src/main/java/io/osv/isolated/MultiJarLoader.java
@@ -73,8 +73,8 @@ private static void runFromFile(String fileName) {
*
* @param line a line from the file
* @return true if this is an executable line, comments and empty
lines are
- * ignored. sleep with a number in millisecond is supported,
and
- * would put the main thread into sleep
+ * ignored. sleep with a number in millisecond is supported, and
+ * would put the main thread into sleep
*/
private static boolean isExec(String line) {
if (line.equals("") || line.startsWith("#")) {
diff --git
a/java/runjava/src/main/java/io/osv/isolated/RunIsolatedJvmApp.java
b/java/runjava/src/main/java/io/osv/isolated/RunIsolatedJvmApp.java
--- a/java/runjava/src/main/java/io/osv/isolated/RunIsolatedJvmApp.java
+++ b/java/runjava/src/main/java/io/osv/isolated/RunIsolatedJvmApp.java
@@ -7,27 +7,28 @@
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/
+
import io.osv.Jvm;
import static io.osv.RunJvmAppHelper.runSync;
import static io.osv.RunJvmAppHelper.JvmFactory;
public class RunIsolatedJvmApp {
- private static native void onVMStop();
+ private static native void onVMStop();
- static {
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- onVMStop();
- }
- });
- }
+ static {
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ public void run() {
+ onVMStop();
+ }
+ });
+ }
public static void main(String[] args) {
runSync(new JvmFactory() {
public Jvm getJvm() {
return IsolatedJvm.getInstance();
}
- },args);
+ }, args);
}
}
diff --git
a/java/runjava/src/main/java/io/osv/nonisolated/NonIsolatedJvm.java
b/java/runjava/src/main/java/io/osv/nonisolated/NonIsolatedJvm.java
--- a/java/runjava/src/main/java/io/osv/nonisolated/NonIsolatedJvm.java
+++ b/java/runjava/src/main/java/io/osv/nonisolated/NonIsolatedJvm.java
@@ -24,28 +24,29 @@ public static NonIsolatedJvm getInstance() {
return instance;
}
- private NonIsolatedJvm() {}
+ private NonIsolatedJvm() {
+ }
@Override
protected Thread run(ClassLoader classLoader, final String classpath,
final String mainClass, final String[] args, final Properties properties) {
thrownException.set(null);
Thread thread = new Thread() {
@Override
public void run() {
- System.setProperty("java.class.path", classpath);
+ System.setProperty("java.class.path", classpath);
- for(Map.Entry<?,?> property : properties.entrySet())
-
System.setProperty(property.getKey().toString(),property.getValue().toString());
//TODO Check for null
+ for (Map.Entry<?, ?> property : properties.entrySet())
+ System.setProperty(property.getKey().toString(),
property.getValue().toString()); //TODO Check for null
- try {
- runMain(loadClass(mainClass), args);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- } catch (MainClassNotFoundException e) {
- thrownException.set(e);
- } catch (Throwable e) {
- getUncaughtExceptionHandler().uncaughtException(this, e);
- }
+ try {
+ runMain(loadClass(mainClass), args);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (MainClassNotFoundException e) {
+ thrownException.set(e);
+ } catch (Throwable e) {
+ getUncaughtExceptionHandler().uncaughtException(this,
e);
+ }
}
};
@@ -82,5 +83,7 @@ protected ClassLoader getParentClassLoader() {
return Thread.currentThread().getContextClassLoader();
}
- public Throwable getThrownExceptionIfAny() { return
thrownException.get(); }
+ public Throwable getThrownExceptionIfAny() {
+ return thrownException.get();
+ }
}
diff --git
a/java/runjava/src/main/java/io/osv/nonisolated/RunNonIsolatedJvmApp.java
b/java/runjava/src/main/java/io/osv/nonisolated/RunNonIsolatedJvmApp.java
---
a/java/runjava/src/main/java/io/osv/nonisolated/RunNonIsolatedJvmApp.java
+++
b/java/runjava/src/main/java/io/osv/nonisolated/RunNonIsolatedJvmApp.java
@@ -13,21 +13,21 @@
import static io.osv.RunJvmAppHelper.JvmFactory;
public class RunNonIsolatedJvmApp {
- private static native void onVMStop();
+ private static native void onVMStop();
- static {
- Runtime.getRuntime().addShutdownHook(new Thread() {
- public void run() {
- onVMStop();
- }
- });
- }
+ static {
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ public void run() {
+ onVMStop();
+ }
+ });
+ }
public static void main(String[] args) {
runSync(new JvmFactory() {
public Jvm getJvm() {
return NonIsolatedJvm.getInstance();
}
- },args);
+ }, args);
}
}
diff --git a/java/runjava/src/main/java/io/osv/util/LazilyInitialized.java
b/java/runjava/src/main/java/io/osv/util/LazilyInitialized.java
--- a/java/runjava/src/main/java/io/osv/util/LazilyInitialized.java
+++ b/java/runjava/src/main/java/io/osv/util/LazilyInitialized.java
@@ -12,12 +12,11 @@
/**
* This class provides thread-safe lazy initialization facility with
* semantics similar to static class initialization.
- *
+ * <p>
* Allows to obtain not-yet-initialized object from the thread which
performs the initialization.
* Creation and initialization may be performed only once.
- *
+ * <p>
* If initialization or construction fails, all subsequent attempts to get
that object will fail with that cause.
- *
*/
public final class LazilyInitialized<T> {
public interface Initializer<T> {
diff --git a/java/runjava/src/main/java/io/osv/util/json/ArrayBuilder.java
b/java/runjava/src/main/java/io/osv/util/json/ArrayBuilder.java
--- a/java/runjava/src/main/java/io/osv/util/json/ArrayBuilder.java
+++ b/java/runjava/src/main/java/io/osv/util/json/ArrayBuilder.java
@@ -10,56 +10,52 @@
/**
* A helper class to create array representative and handle the comma
before
* values
- *
*/
public class ArrayBuilder {
- private boolean first = true;
- private StringBuilder sb = new StringBuilder();
- private String close = "]";
+ private boolean first = true;
+ private StringBuilder sb = new StringBuilder();
+ private String close = "]";
- /**
- * The default constructor is used when the surrounding chars are square
- * braces
- */
- public ArrayBuilder() {
- sb.append("[");
- }
+ /**
+ * The default constructor is used when the surrounding chars are
square
+ * braces
+ */
+ public ArrayBuilder() {
+ sb.append("[");
+ }
- /**
- * A constructor that set an open and close characters
- *
- * @param open
- * the open characters
- * @param close
- * the close characters
- */
- public ArrayBuilder(String open, String close) {
- this.close = close;
- sb.append(open);
- }
+ /**
+ * A constructor that set an open and close characters
+ *
+ * @param open the open characters
+ * @param close the close characters
+ */
+ public ArrayBuilder(String open, String close) {
+ this.close = close;
+ sb.append(open);
+ }
- /**
- * Append a value
- *
- * @param val
- * the value to add
- */
- public StringBuilder append(String val) {
- if (first) {
- first = false;
- } else {
- sb.append(", ");
- }
- return sb.append(val);
- }
+ /**
+ * Append a value
+ *
+ * @param val the value to add
+ */
+ public StringBuilder append(String val) {
+ if (first) {
+ first = false;
+ } else {
+ sb.append(", ");
+ }
+ return sb.append(val);
+ }
- /**
- * Close the array and get a string out of it.
- *
- * @return a string of the array
- */
- public String toString() {
- sb.append(close);
- return sb.toString();
- }
+ /**
+ * Close the array and get a string out of it.
+ *
+ * @return a string of the array
+ */
+ public String toString() {
+ sb.append(close);
+ return sb.toString();
+ }
}
diff --git a/java/runjava/src/main/java/io/osv/util/json/JsonGenerator.java
b/java/runjava/src/main/java/io/osv/util/json/JsonGenerator.java
--- a/java/runjava/src/main/java/io/osv/util/json/JsonGenerator.java
+++ b/java/runjava/src/main/java/io/osv/util/json/JsonGenerator.java
@@ -18,84 +18,78 @@
/**
* This is a helper class to map types to json format.
- *
*/
public class JsonGenerator {
- /**
- * Recursively map an attribute value to string
- *
- * @param value
- * an attribute value
- * @return a string representative of the value
- */
- public static String attrValueToString(Object value) {
- if (value instanceof CompositeData[]) {
- CompositeData data[] = (CompositeData[]) value;
- ArrayBuilder sb = new ArrayBuilder();
- for (int i = 0; i < data.length; i++) {
- sb.append(compositeToString(data[i]));
- }
- return sb.toString();
- }
- if (value instanceof CompositeData) {
- return compositeToString((CompositeData) value);
- }
- if (value instanceof String[]) {
- String vals[] = (String[]) value;
- ArrayBuilder sb = new ArrayBuilder();
- for (int i = 0; i < vals.length; i++) {
- sb.append("\"" + vals[i] + "\"");
- }
- return sb.toString();
- }
- if (value instanceof Long || value instanceof Integer) {
- return value.toString();
- }
- return (value == null) ? "\"\"" : "\"" + value.toString() +
"\"";
- }
+ /**
+ * Recursively map an attribute value to string
+ *
+ * @param value an attribute value
+ * @return a string representative of the value
+ */
+ public static String attrValueToString(Object value) {
+ if (value instanceof CompositeData[]) {
+ CompositeData data[] = (CompositeData[]) value;
+ ArrayBuilder sb = new ArrayBuilder();
+ for (int i = 0; i < data.length; i++) {
+ sb.append(compositeToString(data[i]));
+ }
+ return sb.toString();
+ }
+ if (value instanceof CompositeData) {
+ return compositeToString((CompositeData) value);
+ }
+ if (value instanceof String[]) {
+ String vals[] = (String[]) value;
+ ArrayBuilder sb = new ArrayBuilder();
+ for (int i = 0; i < vals.length; i++) {
+ sb.append("\"" + vals[i] + "\"");
+ }
+ return sb.toString();
+ }
+ if (value instanceof Long || value instanceof Integer) {
+ return value.toString();
+ }
+ return (value == null) ? "\"\"" : "\"" + value.toString() + "\"";
+ }
- /**
- * Recursively map a composite value to a string
- *
- * @param data
- * Composite Data value
- * @return a string representation of the data
- */
- public static String compositeToString(CompositeData data) {
- ArrayBuilder sb = new ArrayBuilder("{", "}");
- for (String key : data.getCompositeType().keySet()) {
- sb.append("\"").append(key).append("\": ")
-
.append(attrValueToString(data.get(key)));
- }
- return sb.toString();
- }
+ /**
+ * Recursively map a composite value to a string
+ *
+ * @param data Composite Data value
+ * @return a string representation of the data
+ */
+ public static String compositeToString(CompositeData data) {
+ ArrayBuilder sb = new ArrayBuilder("{", "}");
+ for (String key : data.getCompositeType().keySet()) {
+ sb.append("\"").append(key).append("\": ")
+ .append(attrValueToString(data.get(key)));
+ }
+ return sb.toString();
+ }
- /**
- * Map an attribute to a string and add its value if present
- *
- * @param att
- * the mbeanServer attribute
- * @param objName
- * the mbeanServer object name
- * @param mbeanServer
- * an mbeanServer server
- * @return a string representative of the attribute in a JSON format
- * @throws ReflectionException
- * @throws MBeanException
- * @throws InstanceNotFoundException
- * @throws AttributeNotFoundException
- */
- public static String attrToString(MBeanAttributeInfo att,
- ObjectName objName, MBeanServer mbeanServer)
- throws AttributeNotFoundException,
InstanceNotFoundException,
- MBeanException, ReflectionException {
- String value = "";
- value = (att.isReadable()) ? attrValueToString(mbeanServer
- .getAttribute(objName, att.getName())) : "\"\"";
+ /**
+ * Map an attribute to a string and add its value if present
+ *
+ * @param att the mbeanServer attribute
+ * @param objName the mbeanServer object name
+ * @param mbeanServer an mbeanServer server
+ * @return a string representative of the attribute in a JSON format
+ * @throws ReflectionException
+ * @throws MBeanException
+ * @throws InstanceNotFoundException
+ * @throws AttributeNotFoundException
+ */
+ public static String attrToString(MBeanAttributeInfo att,
+ ObjectName objName, MBeanServer
mbeanServer)
+ throws AttributeNotFoundException, InstanceNotFoundException,
+ MBeanException, ReflectionException {
+ String value = "";
+ value = (att.isReadable()) ? attrValueToString(mbeanServer
+ .getAttribute(objName, att.getName())) : "\"\"";
- return "{\"name\": \"" + att.getName() + "\", \"type\": \""
- + att.getType() + "\", \"value\": " + value
- + ", \"writable\": " +
Boolean.toString(att.isWritable())
- + ", \"description\": \"" + att.getDescription() +
"\"}";
- }
+ return "{\"name\": \"" + att.getName() + "\", \"type\": \""
+ + att.getType() + "\", \"value\": " + value
+ + ", \"writable\": " + Boolean.toString(att.isWritable())
+ + ", \"description\": \"" + att.getDescription() + "\"}";
+ }
}
diff --git
a/java/tests/src/main/java/io/osv/AllTestsThatTestNonIsolatedApp.java
b/java/tests/src/main/java/io/osv/AllTestsThatTestNonIsolatedApp.java
--- a/java/tests/src/main/java/io/osv/AllTestsThatTestNonIsolatedApp.java
+++ b/java/tests/src/main/java/io/osv/AllTestsThatTestNonIsolatedApp.java
@@ -7,6 +7,7 @@
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/
+
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
diff --git
a/java/tests/src/main/java/io/osv/ClassLoaderWithoutIsolationTest.java
b/java/tests/src/main/java/io/osv/ClassLoaderWithoutIsolationTest.java
--- a/java/tests/src/main/java/io/osv/ClassLoaderWithoutIsolationTest.java
+++ b/java/tests/src/main/java/io/osv/ClassLoaderWithoutIsolationTest.java
@@ -25,7 +25,7 @@ public void
testParentContextSeesModificationsOfStaticFields() throws Throwable
//
// Rethrow any exception that may have been raised and led to the
thread terminating
final Throwable exception =
NonIsolatedJvm.getInstance().getThrownExceptionIfAny();
- if( null != exception)
+ if (null != exception)
throw exception;
//
// There is one class instance of StaticFieldSetter loaded as
there is no isolation
@@ -50,14 +50,12 @@ public void
testChildSeesSameVersionOfAClassDefinedInParentContext() throws Thro
//
// Rethrow any exception that may have been raised and led to the
thread terminating
final Throwable exception =
NonIsolatedJvm.getInstance().getThrownExceptionIfAny();
- if( null != exception && exception instanceof
NoSuchFieldException) {
+ if (null != exception && exception instanceof
NoSuchFieldException) {
// It is what is expected as there is no isolation between
child and parent classloader the class loaded
// by parent classloader from tests.jar which is a first jar
in the classpath
- }
- else if( null != exception) {
+ } else if (null != exception) {
throw exception;
- }
- else {
+ } else {
throw new AssertionError("The field should be also absent in
child context");
}
}
@@ -69,7 +67,7 @@ public void
testClassesDefinedInParentContextAreVisibleToChild() throws Throwabl
//
// Rethrow any exception that may have been raised and led to the
thread terminating
final Throwable exception =
NonIsolatedJvm.getInstance().getThrownExceptionIfAny();
- if( null != exception)
+ if (null != exception)
throw exception;
//
// As there is no isolation between child and parent classloader
the class loaded
diff --git
a/java/tests/src/main/java/io/osv/LoggingWithoutIsolationTest.java
b/java/tests/src/main/java/io/osv/LoggingWithoutIsolationTest.java
--- a/java/tests/src/main/java/io/osv/LoggingWithoutIsolationTest.java
+++ b/java/tests/src/main/java/io/osv/LoggingWithoutIsolationTest.java
@@ -33,11 +33,11 @@ public void testLogger() throws Throwable {
//
// Rethrow any exception that may have been raised and led to the
thread terminating
final Throwable exception =
NonIsolatedJvm.getInstance().getThrownExceptionIfAny();
- if( null != exception)
+ if (null != exception)
throw exception;
final List<String> logLines = readLines(log);
- for( String line : logLines)
+ for (String line : logLines)
System.out.println(line);
assertThat(logLines)
diff --git a/java/tests/src/main/java/io/osv/OsvApiTest.java
b/java/tests/src/main/java/io/osv/OsvApiTest.java
--- a/java/tests/src/main/java/io/osv/OsvApiTest.java
+++ b/java/tests/src/main/java/io/osv/OsvApiTest.java
@@ -12,8 +12,7 @@
*/
public class OsvApiTest {
@Test
- public void testOSvVersionIsSet()
- {
+ public void testOSvVersionIsSet() {
assertThat(System.getProperty("osv.version"))
.isNotEmpty()
.matches("v\\d+\\.\\d+([-a-z0-9]+)?");
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.