diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2010-11-12 16:26:17 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2010-11-12 16:26:17 +0000 |
commit | a061def4dd3d16b226f17a5246470255623177c2 (patch) | |
tree | 2e69c017110eb3a196af9b2c9b865f08f72743f6 /src/fjbg | |
parent | 505a858ea1328227f18d116926a57296fd63dddd (diff) | |
download | scala-a061def4dd3d16b226f17a5246470255623177c2.tar.gz scala-a061def4dd3d16b226f17a5246470255623177c2.tar.bz2 scala-a061def4dd3d16b226f17a5246470255623177c2.zip |
Generate EnclosingMethod classfile attributes.
This should fix java signatures when they refer to
method type parameters. I unrolled Adriaans previous fix
for #3249, as this one is more general. Closes #3249,
review by moors.
Diffstat (limited to 'src/fjbg')
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java | 8 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JEnclosingMethodAttribute.java | 39 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java b/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java index 569a9ac272..07030fbb9c 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/FJBGContext.java @@ -145,6 +145,14 @@ public class FJBGContext { return new JOtherAttribute(this, clazz, owner, name, contents, length); } + public JEnclosingMethodAttribute JEnclosingMethodAttribute(JClass clazz, + String className, + String methodName, + JType methodType) { + return new JEnclosingMethodAttribute(this, clazz, className, methodName, methodType); + } + + public JOtherAttribute JOtherAttribute(JClass clazz, Object owner, String name, diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JEnclosingMethodAttribute.java b/src/fjbg/ch/epfl/lamp/fjbg/JEnclosingMethodAttribute.java new file mode 100644 index 0000000000..4351e2fc7b --- /dev/null +++ b/src/fjbg/ch/epfl/lamp/fjbg/JEnclosingMethodAttribute.java @@ -0,0 +1,39 @@ + +package ch.epfl.lamp.fjbg; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * Sourcefile attribute, which can be attached to class files to + * associate them with their enclosing method. A class may have + * at most one EclosingMethod attribute. + * + * @version 1.0 + * @author Michel Schinz + */ + +public class JEnclosingMethodAttribute extends JAttribute { + protected final int classIdx; + protected final int nameAndTypeIdx; + + public JEnclosingMethodAttribute(FJBGContext context, + JClass clazz, + String className, String methodName, JType methodType) { + super(context, clazz); + this.classIdx = clazz.getConstantPool().addClass(className); + this.nameAndTypeIdx = clazz.getConstantPool().addNameAndType(methodName, methodType.getSignature()); + } + + public String getName() { return "EnclosingMethod"; } + + protected int getSize() { + return 4; + } + + protected void writeContentsTo(DataOutputStream stream) throws IOException { + stream.writeShort(classIdx); + stream.writeShort(nameAndTypeIdx); + } +} |