Commit 255454ab authored by Jesper Öqvist's avatar Jesper Öqvist
Browse files

Release 7.1 of JastAddJ

parent b1e752f7
Java1.4Frontend/AST
Java1.4Backend/AST
Java1.5Frontend/AST
Java1.5Backend/doc
Java7Frontend/AST
Java7Frontend/beaver
Java7Frontend/parser
Java7Frontend/scanner
Java7Frontend/doc
Java7Backend/AST
Java7Backend/beaver
Java7Backend/parser
Java7Backend/scanner
Java7Backend/JavaPrettyPrinter.java
Java7Backend/doc
*.class
Java1.5Backend/AST
Java1.5Backend/beaver
Java1.5Backend/parser
Java1.5Backend/scanner
Java7Backend/JastAddJ.properties
Java1.4Backend/beaver
Java1.4Backend/parser
Java1.4Backend/scanner
Java1.4Frontend/parser/JavaParser.all
Java1.4Frontend/parser/JavaParser.beaver
Java1.4Frontend/parser/JavaParser.java
Java1.4Frontend/scanner/JavaScanner.flex
Java1.4Frontend/scanner/JavaScanner.java
Java1.5Frontend/beaver
Java1.5Frontend/parser/JavaParser.all
Java1.5Frontend/parser/JavaParser.beaver
Java1.5Frontend/parser/JavaParser.java
Java1.5Frontend/scanner/JavaScanner.flex
Java1.5Frontend/scanner/JavaScanner.java
Java1.5Frontend/scanner/Unicode.java
Java7Frontend/JastAddJ.properties
*.sh
*.patch
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="Java7Backend"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="Java1.4Frontend/tools/ant.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>JastAddJ</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
2013-02-13 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Release 7.1
2013-01-25 Jesper Öqvist <jesper@llbit.se>
* Removed unused import java.util.LinkedHashSet
2013-01-23 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Moved PathPart and subclasses to separate .jadd file in Java1.4Frontend
* Improved name checking error messages for TypeDecl
* Package names are double-checked against canonical file names in
order to avoid some problems on case-insensitive file systems.
Trac ticket: http://svn.cs.lth.se/trac/jastadd-trac/ticket/99
2013-01-10 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Fixed error in Java7Frontend/JavaPrettyPrinter.
Properly escape backslash file separator.
2013-01-07 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Don't add system property `java.class.path` to classpath
2012-11-23 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Updated to JastAdd2 version R20121122 (r889)
2012-11-14 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Updated to JastAdd2 version R20121114 (r887)
2012-11-09 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Updated to latest JastAdd2 version
2012-11-06 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Fixed errors in parser rule for annotations, now it is closer to the JLS.
Trac ticket: http://svn.cs.lth.se/trac/jastadd-trac/ticket/87
2012-11-02 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* JastAddJ prints an error message and exits with nonzero exit code when
an unexpected exception occurs
* Fixed error causing NPE during ParMethodDecl type argument substitution
Trac ticket: http://svn.cs.lth.se/trac/jastadd-trac/ticket/86
2012-11-01 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* All type accesses in accessor methods should be qualified
Trac ticket: http://svn.cs.lth.se/trac/jastadd-trac/ticket/85
2012-09-20 (JO)
* Modified beaver.Symbol: made the value field non-final and added custom
clone method. This fixes a "memory leak" when cloning AST nodes.
2012-09-13 (JO)
* The addSourceFile method now returns the CompilationUnit representing
the added source file name
2012-09-12 (ES/JO)
* Applied patch from Emma which fixed a circular type lookup problem
for generic types. The patch added the new inExtendsOrImplements
attribute.
2012-07-18 (JO)
* JastAddJ now uses the relative path to identify compilation units.
The pathName attribute of compilation units may now be different due to
this change.
Using the relative path rather than the absolute path makes it simpler
for static analysis tools to support relocation between different
machines.
2012-06-29 (JO)
* Made field and variable initializer type errors more verbose
* Fixed error in type lookup that could cause duplicate compilation units
to be added in the AST (one as a from-source CU, the other as library CU)
See also http://svn.cs.lth.se/trac/jastadd-trac/ticket/74
2012-05-07 (JO)
Changed the name of the Java7Backend compiler to JastAddJ (JJ7)
Changed the name of the Java7Backend generated Jar file to JJ7.jar
2012-05-04 (JO)
An implementation of createQualifiedAccess was added to AbstractWildcardType
so that wildcard types do not use the default behaviour of creating a
qualified type access with package and type name which are undefined for
wildcard types.
If a corresponding class file and source file have the same last modified
timestamp, then the class file will be parsed rather than the source file.
Final non-static fields now also receive the ConstantValue attribute when
the value is constant.
Fixed error that caused faulty bytecode generation when compiling an
enhanced for statement where the loop variable was a boxed primitive type.
Fixed definite assignment not propagating to second expression in an
assert statement.
Set the ACC_VARARGS flag for variable arity constructors.
2012-05-03 (JO)
The hostType attribute now always returns the "original" TypeDecl, so for
example a method in a generic class may be the child of a ParClassDecl but
hostType will now point to the corresponding GenericClassDecl.
This fixes an error where extraneous accessor methods were generated for
some types of method access that did not require an accessor method.
2012-04-26 (JO)
JastAddJ exits with exit code 0 if it only prints version or help
information. The version string output by -version was also made shorter.
2012-03-24 (JO)
Updated to latest JastAdd2 and RagDoll.
2012-03-06 (JO)
Removed the TypeDecl.subclassWithinBody(TypeDecl) method since the
purpose of that method was to find an enclosing class inheriting from a
given superclass C while determining member accessibility.
Only looking at the directly enclosing subclass of C is not sufficient to
determine the accessibility of the field or method - all enclsing classes
must be checked until one that can access the member is found.
This is the puprpose of the new methods
TypeDecl.mayAccess(Expr, FieldDeclaration)
TypeDecl.mayAccess(MethodAccess, MethodDecl)
2012-02-18 (JO)
Moved the Java7Backend compiler main class to
org.jastadd.jastaddj.JavaCompiler. A main class with the same name remains
in the default package, for backwards compatibility.
2011-12-08 (JO)
Upgraded Beaver to version 0.9.9
The new version of Beaver uses a new naming convention for the Beaver jar
files, an effect of this is that the jar file used for Ant tasks is now
called beaver-ant.jar. Extensions using Beaver in their Ant scripts by
referencing Java1.4Frontend/tools/beaver.jar should be updated to reference
Java1.4Frontend/tools/beaver-ant.jar instead.
2011-11-23 (JO)
Added automatic version number update to build scripts for JJ7.
2011-09-24 (JO)
Updated the JastAdd2 tool to version R20110924.
2011-09-15 (JO)
Added isDefaultConstructor flag to ConstructorDecl. Pretty printing
now ignores auto-generated default constructors. Extensions that rely on
pretty printing to generate default constructors should refine the
setDefaultConstructor method to make it do nothing.
2011-06-03 (JO)
Refactored the Java AST. CatchClause is now an abstract base class
for BasicCatch, which fills the same role that CatchClause previously had.
Extensions that use the old CatchClause node type will have to in some
cases move attribute refines etc. to BasicCatch.
2011-05-12 (JO)
Modified build files to use more heap memory when running JastAdd2
using an exec task.
2011-04-01 (JO)
Errors and warnings are printed on the error stream instead of the
standard output stream.
2011-08-09 (JO)
Added build file to root JastAddJ directory with clean target that
cleans all JastAddJ modules.
2011-08-09 (JO)
Refactored VariableDeclaration.jrag - moved interface Variable to
Variable.jadd
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="executiontests/|licences/|test/" kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path=""/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Java1.4Backend</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
/*
* The JastAdd Extensible Java Compiler (http://jastadd.org) is covered
* by the modified BSD License. You should have received a copy of the
* modified BSD license with this compiler.
*
* Copyright (c) 2005-2008, Torbjorn Ekman
* All rights reserved.
*/
import java.io.*;
aspect Attributes {
class Attribute {
int attribute_name_index;
ByteArrayOutputStream buf = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(buf);
public Attribute(ConstantPool cp, String name) {
attribute_name_index = cp.addUtf8(name);
}
public void emit(DataOutputStream out) throws IOException {
out.writeChar(attribute_name_index);
out.writeInt(buf.size());
buf.writeTo(out);
output.close();
buf.close();
}
public int size() { return buf.size(); }
public void u1(int v) { try { output.writeByte(v); } catch(IOException e) {} }
public void u2(int v) { try { output.writeChar(v); } catch(IOException e) {} }
public void u4(int v) { try { output.writeInt(v); } catch(IOException e) {} }
public void append(byte[] data) { try { output.write(data, 0, data.length); } catch(IOException e) {} }
public void append(Attribute attribute) { try { attribute.emit(output); } catch(IOException e) {} }
}
class SourceFileAttribute extends Attribute {
public SourceFileAttribute(ConstantPool p, String sourcefile) {
super(p, "SourceFile");
u2(p.addUtf8(sourcefile));
}
}
class SyntheticAttribute extends Attribute {
public SyntheticAttribute(ConstantPool p) {
super(p, "Synthetic");
}
}
class ConstantValueAttribute extends Attribute {
public ConstantValueAttribute(ConstantPool p, FieldDeclaration f) {
super(p, "ConstantValue");
int constantvalue_index = f.type().addConstant(p, f.getInit().constant());
u2(constantvalue_index);
}
}
public int TypeDecl.addConstant(ConstantPool p, Constant c) {
if(isString()) return p.addConstant(c.stringValue());
throw new Error("Not supported");
}
public int BooleanType.addConstant(ConstantPool p, Constant c) { return p.addConstant(c.booleanValue() ? 1 : 0); }
public int IntegralType.addConstant(ConstantPool p, Constant c) { return p.addConstant(c.intValue()); }
public int LongType.addConstant(ConstantPool p, Constant c) { return p.addConstant(c.longValue()); }
public int FloatType.addConstant(ConstantPool p, Constant c) { return p.addConstant(c.floatValue()); }
public int DoubleType.addConstant(ConstantPool p, Constant c) { return p.addConstant(c.doubleValue()); }
class InnerClassesAttribute extends Attribute {
public InnerClassesAttribute(TypeDecl typeDecl) {
super(typeDecl.constantPool(), "InnerClasses");
ConstantPool c = typeDecl.constantPool();
Collection list = typeDecl.innerClassesAttributeEntries();
u2(list.size());
for(Iterator iter = list.iterator(); iter.hasNext(); ) {
TypeDecl type = (TypeDecl)iter.next();
u2(c.addClass(type.constantPoolName())); // inner_class_info_index
u2(type.isMemberType() ? c.addClass(type.enclosingType().constantPoolName()) : 0); // outer_class_info_index
u2(type.isAnonymous() ? 0 : c.addUtf8(type.name())); // inner_name_index
u2(type.isInterfaceDecl() ? (type.flags() | Modifiers.ACC_INTERFACE) : type.flags()); // inner_class_access_flags
}
}
}
syn lazy Collection TypeDecl.innerClassesAttributeEntries() {
HashSet list = new HashSet();
if(isNestedType())
list.add(this);
for(Iterator iter = nestedTypes().iterator(); iter.hasNext(); )
list.add(iter.next());
for(Iterator iter = usedNestedTypes().iterator(); iter.hasNext(); )
list.add(iter.next());
return list;
}
class LocalVariableTableAttribute extends Attribute {
public LocalVariableTableAttribute(CodeGeneration gen) {
super(gen.constantPool(), "LocalVariableTable");
u2(gen.localVariableTable.size());
for(Iterator iter = gen.localVariableTable.iterator(); iter.hasNext(); ) {
CodeGeneration.LocalVariableEntry e = (CodeGeneration.LocalVariableEntry)iter.next();
u2(e.start_pc);
u2(e.length);
u2(e.name_index);
u2(e.descriptor_index);
u2(e.index);
}
}
}
class LineNumberTableAttribute extends Attribute {
public LineNumberTableAttribute(CodeGeneration gen) {
super(gen.constantPool(), "LineNumberTable");
u2(gen.lineNumberTable.size());
for(Iterator iter = gen.lineNumberTable.iterator(); iter.hasNext(); ) {
CodeGeneration.LineNumberEntry e = (CodeGeneration.LineNumberEntry)iter.next();
u2(e.start_pc);
u2(e.line_number);
}
}
}
class CodeAttribute extends Attribute {
public CodeAttribute(CodeGeneration codeGen, MethodDecl m) {
super(codeGen.constantPool(), "Code");
u2(codeGen.maxStackDepth());
u2(codeGen.maxLocals());
u4(codeGen.pos()); // code_length
append(codeGen.toArray());
u2(codeGen.exceptions.size());
for(Iterator iter = codeGen.exceptions.iterator(); iter.hasNext(); ) {
CodeGeneration.ExceptionEntry e = (CodeGeneration.ExceptionEntry)iter.next();
u2(e.start_pc);
u2(e.end_pc);
u2(e.handler_pc);
u2(e.catch_type);
}
if(m == null || !m.getModifiers().isSynthetic()) {
u2(2); // Attribute count
append(new LineNumberTableAttribute(codeGen));
append(new LocalVariableTableAttribute(codeGen));
}
else {
u2(0); // Attribute count
}
}
}
interface ExceptionHolder {
public int getNumException();
public Access getException(int i);
}
MethodDecl implements ExceptionHolder;
ConstructorDecl implements ExceptionHolder;
class ExceptionsAttribute extends Attribute {
public ExceptionsAttribute(CodeGeneration gen, ExceptionHolder m) {
super(gen.constantPool(), "Exceptions");
u2(m.getNumException());
for(int i = 0; i < m.getNumException(); i++)
u2(gen.constantPool().addClass(m.getException(i).type().constantPoolName()));
}
}
syn lazy Collection TypeDecl.attributes() {
Collection c = new ArrayList();
if(!innerClassesAttributeEntries().isEmpty())
c.add(new InnerClassesAttribute(this));
if(isSynthetic())
c.add(new SyntheticAttribute(constantPool()));
if(compilationUnit().fromSource()) {
String relativeName = compilationUnit().relativeName();
if(relativeName != null) {
String splitToken = java.io.File.separator;
if(splitToken.equals("\\"))
splitToken = "\\\\";
String[] strings = relativeName.split(splitToken);
c.add(new SourceFileAttribute(constantPool(), strings[strings.length-1]));
}
}
return c;
}
syn lazy Collection BodyDecl.attributes() = new ArrayList();
eq FieldDeclaration.attributes() {
ArrayList l = new ArrayList();
if(isFinal() && isConstant() && (type().isPrimitive() || type().isString()))
l.add(new ConstantValueAttribute(hostType().constantPool(), this));
return l;
}
eq MethodDecl.attributes() {
ArrayList l = new ArrayList();
l.add(new ExceptionsAttribute(bytecodes(hostType().constantPool()), this));
if(isAbstract() || isNative()) return l;
l.add(new CodeAttribute(bytecodes(hostType().constantPool()), this));
if(getModifiers().isSynthetic())
l.add(new SyntheticAttribute(hostType().constantPool()));
return l;
}
eq ConstructorDecl.attributes() {
ArrayList l = new ArrayList();
l.add(new CodeAttribute(bytecodes(hostType().constantPool()), null));
l.add(new ExceptionsAttribute(bytecodes(hostType().constantPool()), this));
if(getModifiers().isSynthetic())
l.add(new SyntheticAttribute(hostType().constantPool()));
return l;
}
syn lazy Collection TypeDecl.clinit_attributes() {
ArrayList l = new ArrayList();
l.add(new CodeAttribute(bytecodes(constantPool()), null));
return l;
}
}
This diff is collapsed.
/*
* The JastAdd Extensible Java Compiler (http://jastadd.org) is covered
* by the modified BSD License. You should have received a copy of the
* modified BSD license with this compiler.
*
* Copyright (c) 2005-2008, Torbjorn Ekman
* All rights reserved.
*/
import java.util.*;
import java.io.*;
aspect ConstantPool {
syn lazy ConstantPool TypeDecl.constantPool() = new ConstantPool(this);
syn lazy String TypeDecl.constantPoolName() {
if(!isNestedType()) {
String packageName = packageName();
if(!packageName.equals("")) {
packageName = packageName.replace('.', '/') + "/";
}
return packageName + name();
}
else {
String prefix = enclosingType().constantPoolName();
if(isAnonymous()) {
return prefix + "$" + uniqueIndex();
}
else if(isLocalClass()) {
return prefix + "$" + uniqueIndex() + name();
}
return prefix + "$" + name();
}
}
syn lazy String ArrayDecl.constantPoolName() = typeDescriptor();
public class ConstantPool {
public TypeDecl typeDecl;
public ConstantPool(TypeDecl typeDecl) {
this.typeDecl = typeDecl;
//if(!typeDecl.isFinal)
// System.out.println("Warning: trying to create constant pool for non final type decl " + typeDecl.fullName());
}
public static final byte CONSTANT_Class = 7;
public static final byte CONSTANT_Fieldref = 9;
public static final byte CONSTANT_Methodref = 10;
public static final byte CONSTANT_InterfaceMethodref = 11;
public static final byte CONSTANT_String = 8;
public static final byte CONSTANT_Integer = 3;
public static final byte CONSTANT_Float = 4;
public static final byte CONSTANT_Long = 5;
public static final byte CONSTANT_Double = 6;
public static final byte CONSTANT_NameAndType = 12;
public static final byte CONSTANT_Utf8 = 1;
private int posCounter = 1;
private ArrayList list = new ArrayList();
private void addCPInfo(CPInfo info) {
list.add(info);
}
// for debugging purposes
public int numElements() {
return list.size();
}
public String toString() {
StringBuffer s = new StringBuffer();
for(Iterator iter = list.iterator(); iter.hasNext(); ) {
s.append(iter.next().toString());
s.append("\n");
}
return s.toString();
}
public void emit(DataOutputStream out) throws IOException {
out.writeChar(posCounter);
for(Iterator iter = list.iterator(); iter.hasNext(); ) {
CPInfo info = (CPInfo)iter.next();
info.emit(out);
}
}
private int labelCounter = 1;
public int newLabel() {
return labelCounter++;
}
private HashMap classConstants = new HashMap();
public int addClass(String name) {
Map map = classConstants;
Object key = name;
if(!map.containsKey(key)) {
CPInfo info = new ConstantClass(addUtf8(name.replace('.', '/')));
info.pos = posCounter; posCounter += info.size();
addCPInfo(info);
map.put(key, info);
String s = info.toString();
return info.pos;
}
CPInfo info = (CPInfo)map.get(key);
return info.pos;
}
private HashMap fieldrefConstants = new HashMap();
public int addFieldref(String classname, String name, String type) {
Map map = fieldrefConstants;
Object key = classname + name + type;
if(!map.containsKey(key)) {
CPInfo info = new ConstantFieldref(addClass(classname), addNameAndType(name, type));
info.pos = posCounter; posCounter += info.size();
addCPInfo(info);
map.put(key, info);
String s = info.toString();
return info.pos;
}
CPInfo info = (CPInfo)map.get(key);
return info.pos;
}
private HashMap methodrefConstants = new HashMap();
public int addMethodref(String classname, String name, String desc) {
Map map = methodrefConstants;
Object key = classname + name + desc;
if(!map.containsKey(key)) {
CPInfo info = new ConstantMethodref(addClass(classname), addNameAndType(name, desc));
info.pos = posCounter; posCounter += info.size();
addCPInfo(info);
map.put(key, info);
String s = info.toString();
return info.pos;
}
CPInfo info = (CPInfo)map.get(key);
return info.pos;
}
private HashMap interfaceMethodrefConstants = new HashMap();
public int addInterfaceMethodref(String classname, String name, String desc) {
Map map = interfaceMethodrefConstants;
Object key = classname + name + desc;
if(!map.containsKey(key)) {
CPInfo info = new ConstantInterfaceMethodref(addClass(classname), addNameAndType(name, desc));
info.pos = posCounter; posCounter += info.size();
addCPInfo(info);
map.put(key, info);
String s = info.toString();
return info.pos;
}
CPInfo info = (CPInfo)map.get(key);
return info.pos;
}
private HashMap nameAndTypeConstants = new HashMap();
public int addNameAndType(String name, String type) {
Map map = nameAndTypeConstants;
Object key = name + type;