|
From: <ls...@us...> - 2007-01-14 20:18:40
|
Revision: 3075
http://jnode.svn.sourceforge.net/jnode/?rev=3075&view=rev
Author: lsantha
Date: 2007-01-14 12:18:39 -0800 (Sun, 14 Jan 2007)
Log Message:
-----------
Fixed instance method lookup in invoke(), java.lang.reflect.Proxy works now.
Modified Paths:
--------------
trunk/core/src/core/org/jnode/vm/VmReflection.java
Modified: trunk/core/src/core/org/jnode/vm/VmReflection.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/VmReflection.java 2007-01-14 17:06:45 UTC (rev 3074)
+++ trunk/core/src/core/org/jnode/vm/VmReflection.java 2007-01-14 20:18:39 UTC (rev 3075)
@@ -24,6 +24,7 @@
import java.lang.reflect.InvocationTargetException;
import org.jnode.vm.annotation.MagicPermission;
+import org.jnode.vm.annotation.PrivilegedActionPragma;
import org.jnode.vm.classmgr.VmField;
import org.jnode.vm.classmgr.VmInstanceField;
import org.jnode.vm.classmgr.VmMethod;
@@ -309,7 +310,8 @@
* @return Object
* @throws InvocationTargetException
*/
- public static Object invoke(VmMethod method, Object o, Object[] args)
+ @PrivilegedActionPragma //todo verify this wrt. security implications
+ public static Object invoke(VmMethod method, Object o, Object[] args)
throws InvocationTargetException {
int argCount = method.getNoArguments();
int argsLength = (args == null) ? 0 : args.length;
@@ -321,7 +323,9 @@
if( o == null )
throw new NullPointerException();
Unsafe.pushObject(o);
- } else {
+ if(!method.isConstructor())
+ method = o.getClass().getVmClass().getMethod(method.getName(), method.getSignature());
+ } else {
method.getDeclaringClass().initialize();
}
for (int i = 0; i < argCount; i++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cr...@us...> - 2008-04-25 12:01:09
|
Revision: 4020
http://jnode.svn.sourceforge.net/jnode/?rev=4020&view=rev
Author: crawley
Date: 2008-04-25 05:01:06 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
Fixed bug 888 (leaving the previous incorrect fix commented out.)
Modified Paths:
--------------
trunk/core/src/core/org/jnode/vm/VmReflection.java
Modified: trunk/core/src/core/org/jnode/vm/VmReflection.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/VmReflection.java 2008-04-25 11:59:50 UTC (rev 4019)
+++ trunk/core/src/core/org/jnode/vm/VmReflection.java 2008-04-25 12:01:06 UTC (rev 4020)
@@ -324,11 +324,21 @@
}
if (!method.isStatic()) {
- if( o == null )
+ if (o == null) {
throw new NullPointerException();
+ }
Unsafe.pushObject(o);
- if(!method.isConstructor())
- method = o.getClass().getVmClass().getMethod(method.getName(), method.getSignature());
+ // This is incorrect ... JDK 1.6 throws IllegalArgumentException if the
+ // class of 'o' is the declaring class of 'method'. Stephen Crawley 2008-04-25.
+// if (!method.isConstructor()) {
+// method = o.getClass().getVmClass().getMethod(method.getName(), method.getSignature());
+// }
+ Class declaringClass = method.getDeclaringClass().asClass();
+ if (!declaringClass.isInstance(o)) {
+ throw new IllegalArgumentException("Target object arg is not an instance of " +
+ declaringClass.getName());
+ }
+
} else {
method.getDeclaringClass().initialize();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2008-06-01 18:38:15
|
Revision: 4174
http://jnode.svn.sourceforge.net/jnode/?rev=4174&view=rev
Author: lsantha
Date: 2008-06-01 11:38:11 -0700 (Sun, 01 Jun 2008)
Log Message:
-----------
Fixed regression when invocation target was checked against declaring class of method.
Modified Paths:
--------------
trunk/core/src/core/org/jnode/vm/VmReflection.java
Modified: trunk/core/src/core/org/jnode/vm/VmReflection.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/VmReflection.java 2008-06-01 15:50:10 UTC (rev 4173)
+++ trunk/core/src/core/org/jnode/vm/VmReflection.java 2008-06-01 18:38:11 UTC (rev 4174)
@@ -332,18 +332,18 @@
if (o == null) {
throw new NullPointerException();
}
- Unsafe.pushObject(o);
- // This is incorrect ... JDK 1.6 throws IllegalArgumentException if the
- // class of 'o' is the declaring class of 'method'. Stephen Crawley 2008-04-25.
-// if (!method.isConstructor()) {
-// method = o.getClass().getVmClass().getMethod(method.getName(), method.getSignature());
-// }
+
+ //todo should we make this check here or on a higher level?
Class declaringClass = method.getDeclaringClass().asClass();
if (!declaringClass.isInstance(o)) {
throw new IllegalArgumentException("Target object arg is not an instance of " +
declaringClass.getName());
}
+ Unsafe.pushObject(o);
+ if (!method.isConstructor()) {
+ method = o.getClass().getVmClass().getMethod(method.getName(), method.getSignature());
+ }
} else {
method.getDeclaringClass().initialize();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|