return TypeX.forRawTypeNames(getName(binding));
}
ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) binding;
- String[] arguments = new String[ptb.arguments.length];
- for (int i = 0; i < arguments.length; i++) {
- if (ptb.arguments[i] instanceof WildcardBinding) {
- WildcardBinding wcb = (WildcardBinding) ptb.arguments[i];
- arguments[i] = getName(((TypeVariableBinding)wcb.typeVariable()).firstBound);
- } else {
- arguments[i] = fromBinding(ptb.arguments[i]).getName();
+
+ String[] arguments = null;
+
+ if (ptb.arguments!=null) { // null can mean this is an inner type of a Parameterized Type with no bounds of its own (pr100227)
+ arguments = new String[ptb.arguments.length];
+ for (int i = 0; i < arguments.length; i++) {
+ if (ptb.arguments[i] instanceof WildcardBinding) {
+ WildcardBinding wcb = (WildcardBinding) ptb.arguments[i];
+ arguments[i] = getName(((TypeVariableBinding)wcb.typeVariable()).firstBound);
+ } else {
+ arguments[i] = fromBinding(ptb.arguments[i]).getName();
+ }
}
}
return TypeX.forParameterizedTypeNames(getName(binding), arguments);
--- /dev/null
+class Outer {
+ class Inner {public void p() {System.err.println("Outer.Inner.p() executing");} }
+ public void m() { new Inner().p(); }
+}
+
+class Generic_Outer<T> {
+ class Inner {public void p() {System.err.println("Generic_Outer.Inner.p() executing");} }
+
+ public void m() { new Inner().p(); }
+}
+
+aspect Injector {
+ int Outer.outer = 1;
+ int Outer.Inner.inner = 2;
+ int Generic_Outer.outer = 3;
+ int Generic_Outer.Inner.inner = 4;
+
+ before(Object o): execution(* p()) && this(o) {
+ if (o instanceof Outer.Inner) {
+ System.err.println("Outer.Inner.inner="+((Outer.Inner)o).inner);
+ }
+ if (o instanceof Generic_Outer.Inner) {
+ System.err.println("Generic_Outer.Inner.inner="+((Generic_Outer.Inner)o).inner);
+ }
+ }
+}
+
+public class pr100227 {
+ public static void main(String []argv) {
+ new Outer().m();
+ new Generic_Outer<String>().m();
+ }
+}
import java.util.List;
+
public class TypeX implements AnnotatedElement {
/**
*/
protected String rawTypeSignature;
- /**
- * If this is a parameterized type, these are its parameters
- */
+ // It is not sufficient to say that a parameterized type with no type parameters in fact
+ // represents a raw type - a parameterized type with no type parameters can represent
+ // an inner type of a parameterized type that specifies no type parameters of its own.
protected TypeX[] typeParameters;
private boolean isParameterized = false;
+ private boolean isRawtype = false;
+
/**
* @param signature the bytecode string representation of this Type
public static TypeX forParameterizedTypeNames(String name, String[] paramTypeNames) {
TypeX ret = TypeX.forName(name);
ret.setParameterized(true);
- ret.typeParameters = new TypeX[paramTypeNames.length];
- for (int i = 0; i < paramTypeNames.length; i++) {
- ret.typeParameters[i] = TypeX.forName(paramTypeNames[i]);
+ ret.typeParameters = null;
+ if (paramTypeNames!=null) {
+ ret.typeParameters = new TypeX[paramTypeNames.length];
+ for (int i = 0; i < paramTypeNames.length; i++) {
+ ret.typeParameters[i] = TypeX.forName(paramTypeNames[i]);
+ }
}
ret.rawTypeSignature = ret.signature;
// sig for e.g. List<String> is Ljava/util/List<Ljava/lang/String;>;
- StringBuffer sigAddition = new StringBuffer();
- sigAddition.append("<");
- for (int i = 0; i < ret.typeParameters.length; i++) {
- sigAddition.append(ret.typeParameters[i].signature);
+ if (ret.typeParameters!=null) {
+ StringBuffer sigAddition = new StringBuffer();
+ sigAddition.append("<");
+ for (int i = 0; i < ret.typeParameters.length; i++) {
+ sigAddition.append(ret.typeParameters[i].signature);
+ }
+ sigAddition.append(">");
+ sigAddition.append(";");
+ ret.signature = ret.signature.substring(0,ret.signature.length()-1) + sigAddition.toString();
}
- sigAddition.append(">");
- sigAddition.append(";");
- ret.signature = ret.signature.substring(0,ret.signature.length()-1) + sigAddition.toString();
return ret;
}
public static TypeX forRawTypeNames(String name) {
TypeX ret = TypeX.forName(name);
ret.setParameterized(true);
+ ret.setRawtype(true);
// FIXME asc no need to mess up the signature is there?
// ret.signature = ret.signature+"#RAW";
return ret;
String name = getName();
if (isParameterized()) {
if (isRawType()) return name;
- else return name.substring(0,name.indexOf("<"));
+ else {
+ if (typeParameters==null) return name;
+ else return name.substring(0,name.indexOf("<"));
+ }
} else {
return name;
}
return signature.startsWith("[");
}
- /**
- * Determines if this represents a parameterized type.
- */
public final boolean isParameterized() {
return isParameterized;
-// return signature.indexOf("<") != -1;
-// //(typeParameters != null) && (typeParameters.length > 0);
}
public final boolean isRawType() {
- return isParameterized && typeParameters==null;
+ return isRawtype;
+// return isParameterized && typeParameters==null;
}
private final void setParameterized(boolean b) {
isParameterized=b;
}
+ private final void setRawtype(boolean b) {
+ isRawtype=b;
+ }
+
+
/**
* Returns a TypeX object representing the effective outermost enclosing type