Revision: 1920b00b9a
Author: Michael Bayne <m...@samskivert.com>
Date: Thu Aug 19 22:12:00 2010
Log: - Fixed bug in deciding whether or not to search enclosing instance
fo...
http://code.google.com/p/ductilej/source/detail?r=1920b00b9a
Revision: ee480a4beb
Author: Michael Bayne <m...@samskivert.com>
Date: Thu Aug 19 22:14:49 2010
Log: Added another interface collision test case. In this case, we
inherit ...
http://code.google.com/p/ductilej/source/detail?r=ee480a4beb
==============================================================================
Revision: 1920b00b9a
Author: Michael Bayne <m...@samskivert.com>
Date: Thu Aug 19 22:12:00 2010
Log: - Fixed bug in deciding whether or not to search enclosing instance
for method.
- Report compile-time-resolved argument types (if we have them) when
throwing a
NoSuchMethodException
http://code.google.com/p/ductilej/source/detail?r=1920b00b9a
Modified:
/src/org/ductilej/runtime/RT.java
=======================================
--- /src/org/ductilej/runtime/RT.java Mon Jul 19 22:58:56 2010
+++ /src/org/ductilej/runtime/RT.java Thu Aug 19 22:12:00 2010
@@ -169,9 +169,10 @@
m = getMethod(cclass, mname, atypes);
if (m == null) {
if (!isInnerInNonStaticContext(cclass)) {
- cclass = cclass.getEnclosingClass();
- receiver = getEnclosingReference(cclass, receiver);
- }
+ break;
+ }
+ cclass = cclass.getEnclosingClass();
+ receiver = getEnclosingReference(cclass, receiver);
}
} while (m == null);
@@ -191,7 +192,7 @@
} while (m == null);
}
- return invoke(checkMethod(m, mname, rclass, args), receiver, args);
+ return invoke(checkMethod(m, mname, rclass, atypes, args),
receiver, args);
}
/**
@@ -206,7 +207,7 @@
Method m = (atypes != null) ? getMethod(clazz, mname, atypes) :
// otherwise we've got to do an expensive search using the
runtime argument types
resolveMethod(clazz, mname, toArgTypes(args));
- return invoke(checkMethod(m, mname, clazz, args), null, args);
+ return invoke(checkMethod(m, mname, clazz, atypes, args), null,
args);
}
/**
@@ -765,12 +766,13 @@
/**
* Helper for {@link #invokeStatic} and {@link #invoke}.
*/
- protected static Method checkMethod (Method m, String mname, Class<?>
clazz, Object[] args)
+ protected static Method checkMethod (
+ Method m, String mname, Class<?> clazz, Class<?>[] atypes,
Object[] args)
{
if (m == null) {
// TODO: if argument mismatch, clarify that, if total method
lacking, clarify that
throw new NoSuchMethodError(
- Debug.format(clazz + "." + mname, "atypes",
toArgTypes(args)));
+ Debug.format(clazz + "." + mname, "ftypes",
atypes, "atypes", toArgTypes(args)));
} else {
return m;
}
==============================================================================
Revision: ee480a4beb
Author: Michael Bayne <m...@samskivert.com>
Date: Thu Aug 19 22:14:49 2010
Log: Added another interface collision test case. In this case, we
inherit "int
size()" from HashMap, which means it remains undetyped. But we also
implement
an application-defined interface which declares an "int size()" method. That
size() method gets detyped to "Object size()" and now our class no longer
implements that interface.
When we strip methods out of interfaces, this is no problem, but stripping
methods causes the bridge method problem. I was thinking about not stripping
the methods out of interfaces and instead synthesizing fail-immediately
methods
any methods that a class fails to implement for a given interface. This
would
solve the bridge method problem, but it would run aground on this new
problem.
Looks like it's back to the difficult solution for bridge methods. Sigh.
http://code.google.com/p/ductilej/source/detail?r=ee480a4beb
Modified:
/src/org/ductilej/tests/ImplInheritTest.java
=======================================
--- /src/org/ductilej/tests/ImplInheritTest.java Tue May 4 16:39:11 2010
+++ /src/org/ductilej/tests/ImplInheritTest.java Thu Aug 19 22:14:49 2010
@@ -5,6 +5,7 @@
import java.util.Arrays;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.zip.Deflater;
import org.junit.Test;
@@ -31,6 +32,18 @@
return 0;
}
}
+
+ public interface Cache {
+ public int size ();
+ }
+
+ public class MyCache extends HashMap<String, String> implements Cache {
+ // this will not be detyped because it overrides an implementation
in Map, but it needs to
+ // be detyped because it's supposed to implement Cache.size, which
has itself been detyped
+ @Override public int size () {
+ return super.size();
+ }
+ }
@Test public void testNoop () {
HasEnding obj = new TestImpl();