Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #14. Task.invoke now invokes static methods correctly via refle…

…ction.

	modified:   .classpath
	modified:   examples/kilim/examples/Reflect.java
	modified:   src/kilim/Task.java
	modified:   src/kilim/mirrors/CachedClassMirrors.java
  • Loading branch information...
commit 42c65b39b1ed1b6f72ea6cc53e8070aae7e62e6a 1 parent 41d2307
@sriram-srinivasan sriram-srinivasan authored
View
2  .classpath
@@ -6,6 +6,6 @@
<classpathentry kind="src" path="test"/>
<classpathentry kind="lib" path="libs/asm-all-2.2.3.jar" sourcepath="/Users/s/sw/asm-2.2.3/src"/>
<classpathentry kind="lib" path="libs/junit.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/1.6.0"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="classes"/>
</classpath>
View
26 examples/kilim/examples/Reflect.java
@@ -9,16 +9,22 @@
@Override
public void execute() throws Pausable, Exception {
int n = test();
- System.out.println("test (normal): " + n);
-
+ System.out.println("test (normal invocation of instance method): " + n);
// Invoking test() via reflection
Method mthd = Reflect.class.getDeclaredMethod("test", new Class[0]);
- Object ret = Task.invoke(mthd, /*static mthd */ null, /* no args */(Object[])null);
- System.out.println("test (reflect): " + ret);
+ Object ret = Task.invoke(mthd, this, /* no args */(Object[])null);
+ System.out.println("test (reflect invocation of instance method): " + ret);
+
+ n = static_test();
+ System.out.println("test (normal invocation of static method): " + n);
+ // Invoking test() via reflection
+ mthd = Reflect.class.getDeclaredMethod("static_test", new Class[0]);
+ ret = Task.invoke(mthd, /* target = */ null, /* no args */(Object[])null);
+ System.out.println("test (reflect invocation of static method): " + ret);
System.exit(0);
}
- public static int test() throws Pausable {
+ public int test() throws Pausable {
int m = 10;
for (int i = 0; i < 2; i++) { // Force multiple yields
Task.sleep(100);
@@ -26,6 +32,16 @@ public static int test() throws Pausable {
}
return m; // must return 40 if all goes well.
}
+
+ public static int static_test() throws Pausable {
+ int m = 10;
+ for (int i = 0; i < 2; i++) { // Force multiple yields
+ Task.sleep(100);
+ m *= 2;
+ }
+ return m; // must return 40 if all goes well.
+ }
+
public static void main(String args[]) {
Reflect ref = new Reflect();
View
1  src/kilim/Task.java
@@ -282,6 +282,7 @@ public static Object invoke(Method mthd, Object target, Object ... args)
return ret;
case Fiber.PAUSING__NO_STATE :
ArgState as = new ArgState();
+ as.obj = target;
as.fargs = fargs;
as.pc = 1;
as.mthd = mthd;
View
5 src/kilim/mirrors/CachedClassMirrors.java
@@ -135,7 +135,6 @@ public boolean isAssignableFrom(ClassMirror c) throws ClassMirrorNotFoundExcepti
// ClassVisitor implementation
- @Override
public void visit(int version, int access, String name, String signature, String superName,
String[] interfaces) {
this.name = name;
@@ -144,8 +143,8 @@ public void visit(int version, int access, String name, String signature, String
this.isInterface = (access & Opcodes.ACC_INTERFACE) > 0;
}
-
- @Override
+
+
public MethodVisitor visitMethod(int access, String name, String desc, String signature,
String[] exceptions) {
if (tmpMethodList == null) {
Please sign in to comment.
Something went wrong with that request. Please try again.