Commits

Jesús Gómez  committed 59d0fb4

Preliminar Java version

  • Participants
  • Parent commits 76927ac

Comments (0)

Files changed (2)

+import java.lang.reflect.*;
+
+class Mwfaui {
+    
+    // Reflection doesn't understand Generic Methods
+    public double f(double x)
+    {
+	return x;
+    }
+
+    // in the case of multiplication and division there are no
+    // built-in interfaces that generalize over numeric types for i
+    public double f2(double x)
+    {
+	return x*x;
+    }
+
+    public double f12(double x)
+    {
+	return x/2;
+    }
+
+    public static void main(String args[])
+    {
+	String fun = args[0];
+	Double x = Double.parseDouble(args[1]);
+	Object arglist[] = {x};
+	Class partypes[] = {Double.TYPE};
+	Method m;
+	try {
+	    m = Class.forName("Mwfaui").getMethod(fun, partypes);
+	    Double r = (Double)m.invoke(new Mwfaui(), arglist);
+	    System.out.println(r);
+	}
+	catch(Throwable e) {
+	    System.err.println(e);
+	}
+    }
+}
 {
   string fun;
   double x;
-  string ou;
 
   typedef double (*g)(double);
   map <string, g> mapfun;