/hg/icedtea-web: Adjusted MethodOverloadResolver to follow LiveC...
jkang at icedtea.classpath.org
jkang at icedtea.classpath.org
Mon Jul 28 15:56:26 UTC 2014
changeset 89083ad99374 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=89083ad99374
author: Jie Kang <jkang at redhat.com>
date: Mon Jul 28 11:55:52 2014 -0400
Adjusted MethodOverloadResolver to follow LiveConnect specification when dealing with superclasses. Now takes into account class hierarchy distance.
2014-06-20 Jie Kang <jkang at redhat.com>
Made adjustments to the MethodOverloadResolver to follow LiveConnect
specification when dealing with superclasses.
* tests/reproducers/simple/JSToJFuncResol/testcases/JSToJFuncResolTest.java:
Removed Known to Fail annotation on test case that is now fixed.
* plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java
Added distance calculation for comparing superclass resolutions.
diffstat:
ChangeLog | 10 ++
plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java | 35 +++++++++-
tests/reproducers/simple/JSToJFuncResol/testcases/JSToJFuncResolTest.java | 1 -
3 files changed, 43 insertions(+), 3 deletions(-)
diffs (139 lines):
diff -r 7973c970afd8 -r 89083ad99374 ChangeLog
--- a/ChangeLog Mon Jul 28 11:16:35 2014 -0400
+++ b/ChangeLog Mon Jul 28 11:55:52 2014 -0400
@@ -1,4 +1,14 @@
+2014-06-20 Jie Kang <jkang at redhat.com>
+
+ Made adjustments to the MethodOverloadResolver to follow LiveConnect
+ specification when dealing with superclasses.
+ * tests/reproducers/simple/JSToJFuncResol/testcases/JSToJFuncResolTest.java:
+ Removed Known to Fail annotation on test case that is now fixed.
+ * plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java
+ Added distance calculation for comparing superclass resolutions.
+
2014-07-28 Jie Kang <jkang at redhat.com>
+
Fix to Java ConsoleOutputPane for lower resolutions. Addresses bug
PR1859 where part of the pane is hidden and unnaccessible when
clicking "Show Details".
diff -r 7973c970afd8 -r 89083ad99374 plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java
--- a/plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java Mon Jul 28 11:16:35 2014 -0400
+++ b/plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java Mon Jul 28 11:55:52 2014 -0400
@@ -104,11 +104,19 @@
static class WeightedCast {
private int cost;
+ private final int distance;
private Object castedObject;
public WeightedCast(int cost, Object castedObject) {
this.cost = cost;
this.castedObject = castedObject;
+ this.distance = 0;
+ }
+
+ public WeightedCast(int cost, Object castedObject, int distance) {
+ this.cost = cost;
+ this.castedObject = castedObject;
+ this.distance = distance;
}
public Object getCastedObject() {
@@ -118,6 +126,10 @@
public int getCost() {
return cost;
}
+
+ public int getDistance() {
+ return distance;
+ }
}
@@ -161,6 +173,7 @@
java.lang.reflect.AccessibleObject[] candidates) {
int lowestCost = Integer.MAX_VALUE;
+ int lowestDistance = Integer.MAX_VALUE;
java.lang.reflect.AccessibleObject cheapestMethod = null;
Object[] cheapestArgs = null;
boolean ambiguous = false;
@@ -168,6 +181,7 @@
methodLoop:
for (java.lang.reflect.AccessibleObject candidate : candidates) {
int methodCost = 0;
+ int distance = 0;
Class<?>[] paramTypes = getParameterTypesFor(candidate);
Object[] castedArgs = new Object[paramTypes.length];
@@ -188,6 +202,7 @@
}
methodCost += weightedCast.getCost();
+ distance = weightedCast.getDistance();
Object castedObj = paramTypeClass.isPrimitive() ?
weightedCast.getCastedObject()
@@ -201,18 +216,20 @@
PluginDebug.debug("Param " + i + " of method " + candidate
+ " has cost " + weightedCast.getCost()
+ + " distance " + weightedCast.getDistance()
+ " original param type " + suppliedParamClass
+ " casted to " + castedObjClass + " isPrimitive="
+ castedObjIsPrim + " value " + castedObj);
}
}
- if (methodCost <= lowestCost) {
+ if (methodCost < lowestCost || (methodCost == lowestCost && distance <= lowestDistance)) {
if (methodCost < lowestCost
|| argumentsAreSubclassesOf(castedArgs, cheapestArgs)) {
lowestCost = methodCost;
cheapestArgs = castedArgs;
cheapestMethod = candidate;
+ lowestDistance = distance;
ambiguous = false;
} else {
ambiguous = true;
@@ -333,7 +350,7 @@
// Class type to superclass type;
if (paramTypeClass.isAssignableFrom(suppliedParamClass)) {
- return new WeightedCast(CLASS_SUPERCLASS_COST, paramTypeClass.cast(suppliedParam));
+ return new WeightedCast(CLASS_SUPERCLASS_COST, paramTypeClass.cast(suppliedParam), classDistance(suppliedParamClass, paramTypeClass));
}
// Any java value to String
@@ -344,6 +361,20 @@
return null;
}
+ private static int classDistance(Class<?> subClass, Class<?> superClass) {
+
+ int distance = 0;
+
+ if (superClass.isAssignableFrom(subClass)) {
+ while (!subClass.equals(superClass)) {
+ subClass = subClass.getSuperclass();
+ distance++;
+ }
+ }
+
+ return distance;
+ }
+
private static WeightedCast getArrayToArrayCastWeightedCost(Object suppliedArray,
Class<?> paramTypeClass) {
diff -r 7973c970afd8 -r 89083ad99374 tests/reproducers/simple/JSToJFuncResol/testcases/JSToJFuncResolTest.java
--- a/tests/reproducers/simple/JSToJFuncResol/testcases/JSToJFuncResolTest.java Mon Jul 28 11:16:35 2014 -0400
+++ b/tests/reproducers/simple/JSToJFuncResol/testcases/JSToJFuncResolTest.java Mon Jul 28 11:55:52 2014 -0400
@@ -118,7 +118,6 @@
@Test
@TestInBrowsers(testIn = { Browsers.all })
@NeedsDisplay
- @KnownToFail
public void AppletJSToJFuncResol_inheritedClassToParent1_Test() throws Exception {
jsToJavaFuncResolTest("inheritedClassToParent1", "applet.getNewOverloadTestHelper3()", "inheritedClassToParent1(OverloadTestHelper2) with JSToJFuncResol$OverloadTestHelper3@");
}
More information about the distro-pkg-dev
mailing list