Crash invoke()'ing Method with "double" as return type

Martin Egholm Nielsen martin@egholm-nielsen.dk
Mon Jun 26 14:31:00 GMT 2006


Hi there,
Just ran into a strange problem on my target: When calling invoke() on a 
java.lang.reflect.Method returning a double, my target crashes with an 
"Illegal instruction" attempting to return:
--- 8< 8< 8< ---
# ./tdr1
Constructing...
Returning double...
Pre non-reflective test on double: 3.14
Constructing...
1 about to invoke: public int 
men.gcjdoublereflection.TestDoubleReflection1.gimmeInt()
Returning int...
2 done invoking: public int 
men.gcjdoublereflection.TestDoubleReflection1.gimmeInt()
3 about to invoke: public double 
men.gcjdoublereflection.TestDoubleReflection1.gimmeDouble()
Returning double...
Illegal instruction
--- 8< 8< 8< ---
(whereas returning "int" works.)
And it's not working on double in general that sucks - output line 3 is 
the output after invoking the same method in a non-reflective manner.
This is on my ancient (hacked) GCJ 3.4.x, running on my PPC405EP 
target... I know it's old - but does it ring a bell?
The program producing the output follows:
=== 8< 8< 8< ===
package men.gcjdoublereflection;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
public class TestDoubleReflection1
{
 public TestDoubleReflection1()
 {
 System.out.println("Constructing...");
 } // constr.
 public int gimmeInt()
 {
 System.out.println("Returning int...");
 return 3;
 } // gimmeInt
 public double gimmeDouble()
 {
 System.out.println("Returning double...");
 return 3.14;
 } // gimmeDouble
 public static void main(String[] args) throws Exception
 {
 System.out.println("Pre non-reflective test on double: "
 + new TestDoubleReflection1().gimmeDouble());
 Class clazz = Class
 .forName("men.gcjdoublereflection.TestDoubleReflection1");
 Constructor constr = clazz.getConstructor(new Class[0]);
 Object instance = constr.newInstance(new Object[0]);
 Method intMethod = clazz.getMethod("gimmeInt", new Class[0]);
 System.out.println("1 about to invoke: " + intMethod);
 intMethod.invoke(instance, new Object[0]);
 System.out.println("2 done invoking: " + intMethod);
 Method doubleMethod = clazz.getMethod("gimmeDouble", new Class[0]);
 System.out.println("3 about to invoke: " + doubleMethod);
 doubleMethod.invoke(instance, new Object[0]);
 System.out.println("4 done invoking: " + doubleMethod);
 } // main
} // TDR1


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /