A Light-weighted Approach for Java Language Plug-in
Date Issued
2007
Date
2007
Author(s)
Chang, Jia-Fu
DOI
en-US
Abstract
To make Java language powerful, we add new features into Java language. Because Java is open source, developers who are familiar with Java technique can modify the compiler, grammar, ClassFileFormat or virtual machine depending on require.
There are two problems existing if we modify the core technique of Java. First, it has high thresholds, because it is hard to translate an idea into a language feature for general programmers. Second, it loses the spirit of “write once, run anywhere”.
In order to avoid this disappearance, this discourse offers a light-weighted strategy which has lower threshold. And we implement an approach according with the light-weighted design. What is called a light-weighted strategy means that we design a plug-in structure but not change the core technique of Java, such as Javac and VM. Plug-in structure is that the position where new features exist is independent of standard Java structure. It is an optional mechanism depending on user’s requirement
The way we choose is to add new features on Javac Traditionally we modify directly Javac to get new Javac with new features. Now we design a plug-in outside Javac, but we can regard them as new Javac in the meaning.
Light-weighted structure needs the implementation to prove, and one of methods is to modify bytecode. Plug-in can be viewed as another compiler. In other words, plug-in is also a part of Javac in the meaning. We take advantage of ClassReader and ClassWriter classes in Javac to access bytecode, and modify bytecode by rules on annotations.
An annotation is a kind of new feature in Java; it is a way of adding metadata to Java source code that can also be available to the programmer at run-time. Many times it is used as an alternative to XML technology.
We offer an implementation which accords with light-weighted structure. First, we read bytecode into internal representation using ClassReader. Then, we modify the internal representation by rules on annotations, because annotations can keep user’s information in bytecode. Finally, we transform internal representation into bytecode using ClassWriter.
We regard annotations as syntaxes of new features, and final bytecode has new features indeed. So, we can claim that Java language has new features by plug-in.
Finally, we implement properties feature of C# to Java language using the light-weighted structure we offered.
Subjects
爪哇
語言新功能
外掛
注釋
二進位表示法
注釋處理工具
爪哇編譯器
Java
new feature
plug-in
annotation
bytecode
apt
Javac
Type
thesis
File(s)![Thumbnail Image]()
Loading...
Name
ntu-96-R94922064-1.pdf
Size
23.31 KB
Format
Adobe PDF
Checksum
(MD5):1a2d74dfc9f7626646590a16fbdcf827
