Title: Group 4: Song Li, Ying Lu,
1Java ParTy Java With Parameterized Types
Tonight Im gonna ParTy like its 1999. Prince
CS655 Programming Languages University of
Virginia Computer Science
- Group 4 Song Li, Ying Lu,
- Hexin Wang, and Michael Walker
- May 1, 2000
2Outline
- Motivation
- Related Work
- Our Solution ParTy
- Evaluation
- Remaining Work
- Conclusion
3Motivation
- Java provides no support for genericity JLS
- Must use Object parameters with type casting
- Performance hit
- Type safety is an issue
4Genericity Potential Benefits
- Ideal scenario
- One generic abstraction that adapts
- Compiled code is JVM-compatible
- Type safety control is just as powerful as
non-generic code - Performance boost in execution speed
- Small code size
5Genericity Potential Benefits
- ParTy scenario
- One generic abstraction that adapts
- Compiled code is JVM-compatible
- Type safety control is just as powerful as
non-generic code - Performance boost in execution speed
- Small code size
6Related Work
- Examine support for type parameters in other
languages - C, Ada, Sather, Eiffel, Haskell, ML
- Examine current proposals for Java extensions
- GJ, PolyJ, Pizza, Agesen et. al.
7Related Work GJ and Pizza Bracha98
- GJ translates into legal JVM bytecode
- Homogeneous genericity
- Substitutes type variables by their bounding
type - usually, Object
- Constrains code size
- Sacrifices speed
- No type constraints
8Related Work PolyJ Liskov97
- Modifies JVM bytecode to express parameterization
- better performance
- small code size
- Adds where clause type constraints a la CLU
LSA77 - Creates a new language
9Related Work Agesen et. al. (Stanford, 1997)
- Insert preprocess step into JVM loader
- no change to JVM
- delays code blowup until load-time!
- No type constraints
- Details of implementation are vague
10Related Work Comparison
11Java ParTy Philosophy
- Provide a powerful, safe, and efficient construct
for designing generic classes without changing
JVM bytecodes - Rule Do not add complexity to Java unless its
usefulness outweighs its complexity
12Our Solution Java ParTy
- Constructed JLS-extended syntax and semantics
- Brief list of features
- type parameters within class or interface
- where clause type constraints
- type parameter can itself be of a parameterized
type
13ParTy Code Example
class myClassltType1, Type2gt where boolean lt(
Type1 t) extends myBaseClass implements
myInterface // class body
14ParTy Implementation
ParTy class A
class AltTgt // body
(1) Generic class A written (2) class B written
to instantiate A with actual types
ParTy class B
Class B Altintgt a AltStringgt b
15ParTy Implementation
ParTy class A
(3) Classes are sent to compiler (4)
Corresponding .pclass created
ParTy compiler
class AltTgt // body
A.pclass file
ParTy class B
Class B Altintgt a AltStringgt b
B.pclass file
16ParTy Implementation
ParTy class A
(5) Regular .class files generated at load-time
ParTy compiler
ParTy preprocessor
class AltTgt // body
A_int .class
A.pclass file
A_String .class
ParTy class B
Class B Altintgt a AltStringgt b
B.pclass file
B.class
17ParTy Implementation
(6) JVM-compatible classes are run
ParTy class A
ParTy compiler
ParTy preprocessor
class AltTgt // body
A_int .class
JVM
A.pclass file
A_String .class
ParTy class B
Class B Altintgt a AltStringgt b
B.pclass file
B.class
18Qualitative Evaluation
- How useful is ParTy?
- Constructed Pair, Set, LinkedList, OrderedSet
generic classes - What restrictions are there?
- No where clause for individual methods
- no implicit type information allowed
- no value parameters within ltgt
19Quantitative Evaluation
- Code size
- blowup delay is good for network transmissions
- Benchmarking
- Ran ParTy code against equivalent Java
- Results...
20Quantitative Evaluation Results
- ParTy yielded code up to 27.6 faster!
21Remaining Work
- Finish ParTy compiler
- add type checks
- Support for primitive types
- Integration of ParTy preprocessor into JVM
ClassLoader - more extensive benchmarking
22Conclusion
23Conclusion
- ParTy provides a powerful, safe, and efficient
construct for designing generic classes without
changing JVM bytecodes - ParTy code size expansion delayed until load time
- ParTy adds only the most useful features of type
parameterization to Java