summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2010-12-30 23:32:18 +0000
committermichelou <michelou@epfl.ch>2010-12-30 23:32:18 +0000
commit096bc81a90b746ea3fa8a5bd8eb9009c08a71082 (patch)
tree5df06808f3f561311865a70adff6abbb8ca2ec07 /lib
parentc0bfbce726c9cb74154ee9f30166feb97bfd0331 (diff)
downloadscala-096bc81a90b746ea3fa8a5bd8eb9009c08a71082.tar.gz
scala-096bc81a90b746ea3fa8a5bd8eb9009c08a71082.tar.bz2
scala-096bc81a90b746ea3fa8a5bd8eb9009c08a71082.zip
fixed (and extended) bytecode reader
IMPORTANT NOTE Modifying code of the FJBG library is a very sensitive task since its write operations are eg. used by the Scala compiler. This SVN commit affects (should affect) only the read operations (which did never work) of the FJBG library. Changes include: - fixed several killer bugs in the bytecode reader (see below). - added missing input stream constructors in several Attribute classes (eg. JBootstrapInvokeDynamic, JEnclosingMethodAttribute, JInnerClassesAttribute) together with the corresponding class registrations in class JAttributeFactory. - added classes JExceptionsTable, JLocalVariableTableAttribute and JStackMapTableAttribute (including corresponding factory methods in class FJBGContext). - overriden method toString in most classes to support output format similar to javap (see below). - did some code cleanup (tabs, etc..). Bug fixes include: - fixed incorrect stream.readInt() in JSourceFileAttribute constructor. - fixed missing code.lineNumbers initialization in JLineNumberTableAttribute constructor. - fixed incorrect code in class util.ByteArray constructor (stream). - added method setCode in class JMethod to link them together. Output of decoded bytecode: The added toString() methods return javap-like formatted strings for the decoded data, eg. for the LocalVariableTable attribute you get the following output: ... LocalVariableTable: Start Length Slot Name Signature 0 6 0 this LTest$; 0 6 1 args [Ljava/lang/String; Executing the following Java code will produce decoded bytecode in a format similar to the command line "javap -p -v -classpath <cpath> <classes>": static void printClass(String filePath) throws Exception { FJBGContext fjbgContext = new FJBGContext(49, 0); DataInputStream in = new DataInputStream(new FileInputStream(filePath)); JClass jclass = fjbgContext.JClass(in); System.out.println(jclass); in.close(); } Mainly for providing a demonstrator of the FJBG reader we added to the FJBG library the main class ch.epfl.lamp.fjbg.Main which behaves similarly to javap, the class file disassembler of the J2SE SDK. For instance the following commands produce (more or less) the same output: ~$ scala ch.epfl.lamp.fjbg.Main -classpath classes 'Test javap -p -v$' ~$ -classpath classes 'Test $' In several cases fjbg.Main will provide more information for access flags (eg. brigde methods) and class file attributes (eg. enclosing methods). TODO - integration of FJBGContext.JLocalVariableTableAttribute into the JVM backend of the Scala compiler (cleaner handling of local variables). - The source code of the FJBG library is currently generated using the compiler option "-source 1.4"; moving to source release 1.5 would allow further code improvements like: List --> List<T> (cast removals) StringBuffer --> StringBuilder (faster implementation) /*@Override*/ --> @Override A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
Diffstat (limited to 'lib')
-rw-r--r--lib/fjbg.jar.desired.sha12
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/fjbg.jar.desired.sha1 b/lib/fjbg.jar.desired.sha1
index 25a98b9fe9..fd3def241f 100644
--- a/lib/fjbg.jar.desired.sha1
+++ b/lib/fjbg.jar.desired.sha1
@@ -1 +1 @@
-61cc3142a929ae79b7c905b2f094d429a837b4b2 ?fjbg.jar
+bd8e22a955eeb82671c5fdb8a7a14bc7f25e9eb1 ?fjbg.jar