Skip to content

Commit

Permalink
Use Java 1.6 as the target for J2V8
Browse files Browse the repository at this point in the history
To support more platforms, J2V8 now builds against 1.6. It will now 
run on 1.6, 1.7 and 1.8.
  • Loading branch information
irbull committed May 15, 2015
1 parent b5b3226 commit 5f52f04
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 68 deletions.
8 changes: 4 additions & 4 deletions .classpath
Expand Up @@ -12,18 +12,18 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
Expand Down
7 changes: 4 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs
@@ -1,15 +1,16 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.formatter.align_type_members_on_columns=true
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -68,8 +68,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/eclipsesource/v8/V8.java
Expand Up @@ -44,7 +44,7 @@ class MethodDescriptor {
boolean includeReceiver;
}

Map<Integer, MethodDescriptor> functions = new HashMap<>();
Map<Integer, MethodDescriptor> functions = new HashMap<Integer, MethodDescriptor>();

private synchronized static void load(final String tmpDirectory) {
try {
Expand Down Expand Up @@ -341,7 +341,9 @@ protected Object callObjectJavaMethod(final int methodID, final V8Object receive
return checkResult(result);
} catch (InvocationTargetException e) {
throw e.getTargetException();
} catch (IllegalAccessException | IllegalArgumentException e) {
} catch (IllegalAccessException e) {
throw e;
} catch (IllegalArgumentException e) {
throw e;
} finally {
releaseArguments(args, hasVarArgs);
Expand Down Expand Up @@ -376,7 +378,9 @@ protected void callVoidJavaMethod(final int methodID, final V8Object receiver, f
methodDescriptor.method.invoke(methodDescriptor.object, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
} catch (IllegalAccessException | IllegalArgumentException e) {
} catch (IllegalAccessException e) {
throw e;
} catch (IllegalArgumentException e) {
throw e;
} finally {
releaseArguments(args, hasVarArgs);
Expand Down Expand Up @@ -419,7 +423,7 @@ private Object[] getArgs(final V8Object receiver, final MethodDescriptor methodD
}

private List<Object> populateParamters(final V8Array parameters, final int varArgIndex, final Object[] args, final boolean includeReceiver) {
List<Object> varArgs = new ArrayList<>();
List<Object> varArgs = new ArrayList<Object>();
int start = 0;
if (includeReceiver) {
start = 1;
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/com/eclipsesource/v8/utils/V8ObjectUtils.java
Expand Up @@ -28,7 +28,7 @@ public class V8ObjectUtils {
if (object == null) {
return Collections.emptyMap();
}
Map<String, ? super Object> result = new HashMap<>();
Map<String, ? super Object> result = new HashMap<String, Object>();
String[] keys = object.getKeys();
for (String key : keys) {
result.put(key, getValue(object, key));
Expand All @@ -40,7 +40,7 @@ public static List<? super Object> toList(final V8Array array) {
if (array == null) {
return Collections.emptyList();
}
List<? super Object> result = new ArrayList<>();
List<? super Object> result = new ArrayList<Object>();
for (int i = 0; i < array.length(); i++) {
result.add(getValue(array, i));
}
Expand Down Expand Up @@ -139,17 +139,17 @@ public static void pushValue(final V8 v8, final V8Array result, final Object val
if (value == null) {
result.pushUndefined();
} else if (value instanceof Integer) {
result.push((int) value);
result.push((Integer) value);
} else if (value instanceof Long) {
result.push((int) (long) value);
result.push((int) (long) (Long) value);
} else if (value instanceof Double) {
result.push((double) value);
result.push((Double) value);
} else if (value instanceof Float) {
result.push((float) value);
result.push((Float) value);
} else if (value instanceof String) {
result.push((String) value);
} else if (value instanceof Boolean) {
result.push((boolean) value);
result.push((Boolean) value);
} else if (value instanceof Map) {
V8Object object = toV8Object(v8, (Map) value);
result.push(object);
Expand All @@ -168,17 +168,17 @@ private static void setValue(final V8 v8, final V8Object result, final String ke
if (value == null) {
result.addUndefined(key);
} else if (value instanceof Integer) {
result.add(key, (int) value);
result.add(key, (Integer) value);
} else if (value instanceof Long) {
result.add(key, (int) (long) value);
result.add(key, (int) (long) (Long) value);
} else if (value instanceof Double) {
result.add(key, (double) value);
result.add(key, (Double) value);
} else if (value instanceof Float) {
result.add(key, (float) value);
result.add(key, (Float) value);
} else if (value instanceof String) {
result.add(key, (String) value);
} else if (value instanceof Boolean) {
result.add(key, (boolean) value);
result.add(key, (Boolean) value);
} else if (value instanceof Map) {
V8Object object = toV8Object(v8, (Map) value);
result.add(key, object);
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/eclipsesource/v8/V8CallbackTest.java
Expand Up @@ -662,8 +662,8 @@ public void testIntMethodCalledWithParameters() {
@Override
public Integer answer(final InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
int x = (int) args[0];
int y = (int) args[1];
int x = (Integer) args[0];
int y = (Integer) args[1];
return x + y;
}

Expand All @@ -684,8 +684,8 @@ public void testDoubleMethodCalledWithParameters() {
@Override
public Double answer(final InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
double x = (double) args[0];
double y = (double) args[1];
double x = (Double) args[0];
double y = (Double) args[1];
return x + y;
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/eclipsesource/v8/V8JSFunctionCallTest.java
Expand Up @@ -221,7 +221,7 @@ public void testFunctionCallWithDoubleReturn() {

Object result = v8.executeFunction("getFoo", null);

assertEquals(33.3, (double) result, 0.000001);
assertEquals(33.3, (Double) result, 0.000001);
}

@Test
Expand All @@ -239,7 +239,7 @@ public void testFunctionCallWithBooleanReturn() {

Object result = v8.executeFunction("getFoo", null);

assertTrue((boolean) result);
assertTrue((Boolean) result);
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/eclipsesource/v8/V8MultiThreadTest.java
Expand Up @@ -23,7 +23,7 @@
public class V8MultiThreadTest {

private V8 runtime = null;
private List<Object> mergeSortResults = new ArrayList<>();
private List<Object> mergeSortResults = new ArrayList<Object>();

@Test
public void testKillThread() throws InterruptedException {
Expand Down Expand Up @@ -112,7 +112,7 @@ public void run() {
@Test
public void testMultiV8Threads() throws InterruptedException {

final List<Thread> threads = new ArrayList<>();
final List<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < 10; i++) {
Thread t = new Thread(new Runnable() {

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/eclipsesource/v8/V8Test.java
Expand Up @@ -325,7 +325,7 @@ public void testAnyScriptReturnInt() {
public void testAnyScriptReturnDouble() {
Object result = v8.executeScript("1.1;");

assertEquals(1.1, (double) result, 0.000001);
assertEquals(1.1, (Double) result, 0.000001);
}

@Test
Expand All @@ -339,7 +339,7 @@ public void testAnyScriptReturnString() {
public void testAnyScriptReturnBoolean() {
Object result = v8.executeScript("false;");

assertFalse((boolean) result);
assertFalse((Boolean) result);
}

@Test
Expand Down

0 comments on commit 5f52f04

Please sign in to comment.