CSC/ECE 517 Summer 2008/wiki1 3 jb: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 4: | Line 4: | ||
==Reflection in Java== | ==Reflection in Java== | ||
<source lang= | <source lang=c> | ||
import java.lang.reflect.*; | import java.lang.reflect.*; |
Revision as of 17:46, 31 May 2008
This wiki will explore how reflection is implemented with both Ruby and Java, with the goal of showing which language's implementation makes it easier to write, easier to understand, and more efficient.
Basics
Reflection in Java
import java.lang.reflect.*;
class MountainBike
{
boolean diskBrakes() { return true; }
boolean knobbyTires() { return true; }
public static void main (String argv[])
{
Class c = MountainBike.class;
Method methods[] = c.getDeclaredMethods();
for (int i=0; i<methods.length; i++)
{
System.out.println(methods[i].getName());
}
}
}
Reflection in Ruby
Java Reflection Links
http://java.sun.com/docs/books/tutorial/reflect/index.html
http://java.sun.com/developer/technicalArticles/ALT/Reflection/index.html
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/package-summary.html