324-lecture8 - CSC324: Principles of Programming Languages...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSC324: Principles of Programming Languages ecture 8 University of Toronto Lecture 8 Java’s Reflection Wael Aboulsaadat CSC324: Principles of Programming Languages Internal Representation of .class (Java’s bytecode) public class Point { public Point(int x, int y) { x = 5; Y = 10; } 5 x object University of Toronto public int getX() { return x; } public int getY() { return y; } protected int x, y; } 3 {} {} {} Point(int,int) getX() getY() y class CSC324: Principles of Programming Languages The class Class Instances of the class Class store information about classes u Class name u Inheritance University of Toronto u Interfaces implemented u Methods, members, etc. Can look up instances: u By name u From an object CSC324: Principles of Programming Languages Discovering the type of a Class University of Toronto CSC324: Principles of Programming Languages Discovering the Methods of a class University of Toronto CSC324: Principles of Programming Languages Calling a Method using Reflection 1. Look up a method based on its signature: the name and list of parameter types 2. Specify signature as a comma-separated list of Class objects pecifies the types of arguments University of Toronto u Specifies the types of arguments u Special values for types like int and boolean 3. Call the method, passing in parameters and capturing return value CSC324: Principles of Programming Languages...
View Full Document

This document was uploaded on 08/02/2011.

Page1 / 27

324-lecture8 - CSC324: Principles of Programming Languages...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online