summaryrefslogtreecommitdiff
path: root/src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java')
-rw-r--r--src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java
index e4478728ae..46090b77e9 100644
--- a/src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java
+++ b/src/fjbg/ch/epfl/lamp/fjbg/JSourceFileAttribute.java
@@ -1,3 +1,7 @@
+/* FJBG -- Fast Java Bytecode Generator
+ * Copyright 2002-2011 LAMP/EPFL
+ * @author Michel Schinz
+ */
package ch.epfl.lamp.fjbg;
@@ -9,8 +13,11 @@ import java.io.IOException;
* Sourcefile attribute, which can be attached to class files to
* associate them with their source file.
*
- * @version 1.0
+ * There can be no more than one SourceFile attribute in the attributes table
+ * of a given ClassFile structure. See section 4.8.9 of the JVM specification.
+ *
* @author Michel Schinz
+ * @version 1.0
*/
public class JSourceFileAttribute extends JAttribute {
@@ -32,8 +39,8 @@ public class JSourceFileAttribute extends JAttribute {
int size,
DataInputStream stream)
throws IOException {
- super(context, clazz);
- stream.readInt(); // ignore size
+ super(context, clazz, name);
+
this.sourceFileIndex = stream.readShort();
this.sourceFileName = clazz.getConstantPool().lookupUtf8(sourceFileIndex);
@@ -42,8 +49,18 @@ public class JSourceFileAttribute extends JAttribute {
public String getName() { return "SourceFile"; }
+ public String getFileName() { return sourceFileName; }
+
+ // Follows javap output format for SourceFile attribute.
+ /*@Override*/ public String toString() {
+ StringBuffer buf = new StringBuffer(" SourceFile: \"");
+ buf.append(sourceFileName);
+ buf.append("\"\n");
+ return buf.toString();
+ }
+
protected int getSize() {
- return 2;
+ return 2; // Short.SIZE
}
protected void writeContentsTo(DataOutputStream stream) throws IOException {