|
From: <ls...@us...> - 2007-06-16 19:46:41
|
Revision: 3249
http://jnode.svn.sourceforge.net/jnode/?rev=3249&view=rev
Author: lsantha
Date: 2007-06-16 12:46:39 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Openjdk style getClassContext() implementation to support NativeReflection..
Modified Paths:
--------------
trunk/core/src/core/org/jnode/vm/VmSystem.java
Modified: trunk/core/src/core/org/jnode/vm/VmSystem.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/VmSystem.java 2007-06-16 19:28:56 UTC (rev 3248)
+++ trunk/core/src/core/org/jnode/vm/VmSystem.java 2007-06-16 19:46:39 UTC (rev 3249)
@@ -402,6 +402,37 @@
}
/**
+ * Gets the current stacktrace as array of classes excluding the calls to
+ * java.lang.reflect.Method.invoke() and org.jnode.vm.VmReflection.invoke().
+ *
+ * @return Class[]
+ */
+ public static Class[] getRealClassContext() {
+ final VmStackReader reader = VmProcessor.current().getArchitecture()
+ .getStackReader();
+ final VmStackFrame[] stack = reader.getVmStackTrace(VmMagic
+ .getCurrentFrame(), null, VmThread.STACKTRACE_LIMIT);
+ final int count = stack.length;
+ final Class[] result = new Class[count];
+ int real_count = 0;
+ for (int i = 0; i < count; i++) {
+ VmMethod method = stack[i].getMethod();
+ VmType<?> clazz = method.getDeclaringClass();
+ if((method.getName().equals("invoke") && (
+ clazz.getName().equals("java.lang.reflect.Method") ||
+ clazz.getName().equals("org.jnode.vm.VmReflection"))))
+ continue;
+
+ result[real_count++] = clazz.asClass();
+ }
+
+ Class[] real_result = new Class[real_count];
+ System.arraycopy(result, 0, real_result, 0, real_count);
+
+ return real_result;
+ }
+
+ /**
* Do nothing, until interrupted by an interrupts.
*/
public static void idle() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|