This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
question about reflection
- To: java-discuss at sourceware dot cygnus dot com
- Subject: question about reflection
- From: Godmar Back <gback at cs dot utah dot edu>
- Date: Wed, 24 Nov 1999 16:26:00 -0700 (MST)
Hi,
I'm a bit confused about how reflection is going to work in gcj.
>From looking at class.c:make_class_data, it appears that private methods
are omitted from the method table if inlining or optimization is
turned on.
As a result, they won't be available for reflection in such
functions as Class.getDeclaredMethod(s).
Is this intended?
- Godmar
ps: I tried to test it myself, but I couldn't get gcj's reflection
to work at all: getDeclaredMethod is unimplemented, and getDeclaredMethods
gives me this:
> cat TReflection.java
import java.lang.reflect.*;
public class TReflection
{
public static void main(String av[]) throws Exception {
Class c = Class.forName("TReflection");
Method []m = c.getDeclaredMethods();
for (int i = 0; i < m.length; i++) {
System.out.println(m[i]);
}
}
}
> gcj -g TReflection.java --main=TReflection
> gdb a.out
GNU gdb 4.17.0.4 with Linux/x86 hardware watchpoint and FPU support
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) run
Starting program: /x/gback/transvirtual/tmp/gcjpure/a.out
Program received signal SIGSEGV, Segmentation fault.
java::lang::Class::isPrimitive (this=0x0)
at ../../../libgcj/libjava/java/lang/Class.h:133
133 return vtable == JV_PRIMITIVE_VTABLE;
Current language: auto; currently c++
(gdb) bt
#0 java::lang::Class::isPrimitive (this=0x0)
at ../../../libgcj/libjava/java/lang/Class.h:133
#1 0x400f6160 in java.lang.Class.toString (this=0x0)
at ../../../libgcj/libjava/java/lang/Class.java:137
#2 0x400bd3d7 in java.lang.reflect.Method.toString (this=0x8065d98)
at ../../../libgcj/libjava/java/lang/reflect/Method.java:79
#3 0x400a512b in java.io.PrintStream.println (this=0x8060d20, obj=0x8065d98)
at ../../../libgcj/libjava/java/io/PrintStream.java:215
#4 0x8048b71 in TReflection.main (av=0x8069ff0) at TReflection.java:10
#5 0x400fad5d in java::lang::FirstThread::run (this=0x8061f90)
at ../../../libgcj/libjava/java/lang/natFirstThread.cc:52
#6 0x400b890a in java.lang.Thread.run_ (this=0x8061f90)
at ../../../libgcj/libjava/java/lang/Thread.java:119
#7 0x400ff9be in java::lang::Thread::run__ (obj=0x8061f90)
at ../../../libgcj/libjava/java/lang/natThread.cc:286
#8 0x4010ee52 in _Jv_ThreadStart (thread=0x8061f90,
meth=0x400ff9a0 <java::lang::Thread::run__(java::lang::Object *)>)
at ../../../libgcj/libjava/no-threads.cc:28
#9 0x400ffa3b in java::lang::Thread::start (this=0x8061f90)
at ../../../libgcj/libjava/java/lang/natThread.cc:299
#10 0x4008948e in JvRunMain (klass=0x8049d20, argc=1, argv=0xbffff6b4)
at ../../../libgcj/libjava/prims.cc:793
#11 0x8048bd5 in main (argc=1, argv=0xbffff6b4) at /tmp/cczEAKEomain.i:11
(gdb)