Revision: 9799
Author: [email protected]
Date: Thu Mar 3 06:57:33 2011
Log: Formatting changes with updated Eclipse GWT Format settings for issue
1373803
(see http://gwt-code-reviews.appspot.com)
Review at http://gwt-code-reviews.appspot.com/1371806
Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=9799
Modified:
/trunk/dev/core/src/com/google/gwt/dev/javac/typemodel/TypeOracle.java
/trunk/dev/core/test/com/google/gwt/dev/javac/TypeOracleMediatorTestBase.java
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/javac/typemodel/TypeOracle.java
Wed Mar 2 06:04:24 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/javac/typemodel/TypeOracle.java
Thu Mar 3 06:57:33 2011
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may
not
* use this file except in compliance with the License. You may obtain a
copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -53,7 +53,7 @@
* identity relative to this type oracle instance. Consequently, you can
* reliably compare object identity of any objects this type oracle
produces.
* For example, the following code relies on this stable identity
guarantee:
- *
+ *
* <pre>
* JClassType o = typeOracle.getJavaLangObject();
* JClassType s1 = typeOracle.getType("java.lang.String");
@@ -63,9 +63,9 @@
* JParameterizedType ls =
typeOracle.parse("java.util.List<java.lang.String>");
* assert (ls.getTypeArgs()[0] == s1);
* </pre>
- *
+ *
* </p>
- *
+ *
*/
public class TypeOracle extends
com.google.gwt.core.ext.typeinfo.TypeOracle {
@@ -74,8 +74,7 @@
private final JGenericType genericType;
private final com.google.gwt.core.ext.typeinfo.JClassType[] typeArgs;
- public ParameterizedTypeKey(JGenericType genericType,
- JClassType enclosingType,
+ public ParameterizedTypeKey(JGenericType genericType, JClassType
enclosingType,
com.google.gwt.core.ext.typeinfo.JClassType[] typeArgs) {
this.genericType = genericType;
this.enclosingType = enclosingType;
@@ -88,16 +87,14 @@
return false;
}
ParameterizedTypeKey other = (ParameterizedTypeKey) obj;
- return genericType == other.genericType
- && enclosingType == other.enclosingType
+ return genericType == other.genericType && enclosingType ==
other.enclosingType
&& Arrays.equals(typeArgs, other.typeArgs);
}
@Override
public int hashCode() {
return 29 * genericType.hashCode() + 17
- * ((enclosingType == null) ? 0 : enclosingType.hashCode())
- + Arrays.hashCode(typeArgs);
+ * ((enclosingType == null) ? 0 : enclosingType.hashCode()) +
Arrays.hashCode(typeArgs);
}
}
@@ -251,8 +248,7 @@
return strings.toArray(NO_STRINGS);
}
- private static JClassType[] cast(
- com.google.gwt.core.ext.typeinfo.JClassType[] extTypeArgs) {
+ private static JClassType[]
cast(com.google.gwt.core.ext.typeinfo.JClassType[] extTypeArgs) {
JClassType[] result = new JClassType[extTypeArgs.length];
System.arraycopy(extTypeArgs, 0, result, 0, extTypeArgs.length);
return result;
@@ -265,7 +261,8 @@
private final Map<String, JRealClassType> allTypes = new HashMap<String,
JRealClassType>();
/**
- * Cached types that represent Arrays of other types. These types are
created as needed.
+ * Cached types that represent Arrays of other types. These types are
created
+ * as needed.
*/
@SuppressWarnings("unchecked")
private final Map<JType, JArrayType> arrayTypes = new
ReferenceIdentityMap(
@@ -281,7 +278,8 @@
/**
* Maps SingleJsoImpl interfaces to the implementing JSO subtype.
*/
- private final Map<JClassType, JClassType> jsoSingleImpls = new
IdentityHashMap<JClassType, JClassType>();
+ private final Map<JClassType, JClassType> jsoSingleImpls =
+ new IdentityHashMap<JClassType, JClassType>();
/**
* Cached map of all packages thus far encountered.
@@ -289,12 +287,12 @@
private final Map<String, JPackage> packages = new HashMap<String,
JPackage>();
/**
- * Subclasses of generic types that have type parameters filled in.
These types are created
- * as needed.
+ * Subclasses of generic types that have type parameters filled in. These
+ * types are created as needed.
*/
@SuppressWarnings("unchecked")
- private final Map<ParameterizedTypeKey, JParameterizedType>
parameterizedTypes = new ReferenceMap(
- AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK, true);
+ private final Map<ParameterizedTypeKey, JParameterizedType>
parameterizedTypes =
+ new ReferenceMap(AbstractReferenceMap.HARD,
AbstractReferenceMap.WEAK, true);
/**
* A list of recently-added types that will be fully initialized on the
next
@@ -317,7 +315,7 @@
/**
* Attempts to find a package by name. All requests for the same package
* return the same package object.
- *
+ *
* @return <code>null</code> if the package could not be found
*/
@Override
@@ -327,11 +325,11 @@
/**
* Finds a class or interface given its fully-qualified name.
- *
+ *
* @param name fully-qualified class/interface name - for nested
classes, use
* its source name rather than its binary name (that is, use
a "."
* rather than a "$")
- *
+ *
* @return <code>null</code> if the type is not found
*/
@Override
@@ -344,7 +342,7 @@
* Finds a type given its package-relative name. For nested classes, use
its
* source name rather than its binary name (that is, use a "." rather
than a
* "$").
- *
+ *
* @return <code>null</code> if the type is not found
*/
@Override
@@ -364,7 +362,7 @@
* Gets the type object that represents an array of the specified type.
The
* returned type always has a stable identity so as to guarantee that all
* calls to this method with the same argument return the same object.
- *
+ *
* @param componentType the component type of the array, which can
itself be
* an array type
* @return a type object representing an array of the component type
@@ -416,7 +414,7 @@
/**
* Gets a package by name. All requests for the same package return the
same
* package object.
- *
+ *
* @return the package object associated with the specified name
*/
@Override
@@ -430,7 +428,7 @@
/**
* Gets an array of all packages known to this type oracle.
- *
+ *
* @return an array of packages, possibly of zero-length
*/
@Override
@@ -443,7 +441,7 @@
* specified raw type and a set of type arguments. The returned type
always
* has a stable identity so as to guarantee that all calls to this
method with
* the same arguments return the same object.
- *
+ *
* @param genericType a generic base class
* @param enclosingType
* @param typeArgs the type arguments bound to the specified generic type
@@ -462,8 +460,7 @@
JGenericType genericType = (JGenericType) extGenericType;
JClassType enclosingType = (JClassType) extEnclosingType;
JClassType[] typeArgs = cast(extTypeArgs);
- ParameterizedTypeKey key = new ParameterizedTypeKey(genericType,
- enclosingType, typeArgs);
+ ParameterizedTypeKey key = new ParameterizedTypeKey(genericType,
enclosingType, typeArgs);
JParameterizedType result = parameterizedTypes.get(key);
if (result != null) {
return result;
@@ -471,8 +468,7 @@
if (genericType.isMemberType() && !genericType.isStatic()) {
if (genericType.getEnclosingType().isGenericType() != null
- && enclosingType.isParameterized() == null
- && enclosingType.isRawType() == null) {
+ && enclosingType.isParameterized() == null &&
enclosingType.isRawType() == null) {
/*
* If the generic type is a non-static member type enclosed by a
generic
* type then the enclosing type for this parameterized type should
be
@@ -481,8 +477,7 @@
throw new IllegalArgumentException("Generic type '"
+ genericType.getParameterizedQualifiedSourceName()
+ "' is a non-static member type, but the enclosing type '"
- + enclosingType.getQualifiedSourceName()
- + "' is not a parameterized or raw type");
+ + enclosingType.getQualifiedSourceName() + "' is not a
parameterized or raw type");
}
}
@@ -511,7 +506,7 @@
* specified raw type and a set of type arguments. The returned type
always
* has a stable identity so as to guarantee that all calls to this
method with
* the same arguments return the same object.
- *
+ *
* @param genericType a generic base class
* @param typeArgs the type arguments bound to the specified generic type
* @return a type object representing this particular binding of type
@@ -545,8 +540,7 @@
* implementation is defined.
*/
@Override
- public JClassType getSingleJsoImpl(
- com.google.gwt.core.ext.typeinfo.JClassType intf) {
+ public JClassType
getSingleJsoImpl(com.google.gwt.core.ext.typeinfo.JClassType intf) {
assert intf.isInterface() == intf;
return jsoSingleImpls.get(intf);
}
@@ -564,7 +558,7 @@
* Finds a type given its fully qualified name. For nested classes, use
its
* source name rather than its binary name (that is, use a "." rather
than a
* "$").
- *
+ *
* @return the specified type
*/
@Override
@@ -581,12 +575,11 @@
* Finds a type given its package-relative name. For nested classes, use
its
* source name rather than its binary name (that is, use a "." rather
than a
* "$").
- *
+ *
* @return the specified type
*/
@Override
- public JClassType getType(String pkgName, String topLevelTypeSimpleName)
- throws NotFoundException {
+ public JClassType getType(String pkgName, String topLevelTypeSimpleName)
throws NotFoundException {
assert Name.isSourceName(topLevelTypeSimpleName);
JClassType type = findType(pkgName, topLevelTypeSimpleName);
if (type == null) {
@@ -597,7 +590,7 @@
/**
* Gets all types, both top-level and nested.
- *
+ *
* @return an array of types, possibly of zero length
*/
@Override
@@ -606,8 +599,7 @@
JClassType[] result = values.toArray(new JClassType[values.size()]);
Arrays.sort(result, new Comparator<JClassType>() {
public int compare(JClassType o1, JClassType o2) {
- return o1.getQualifiedSourceName().compareTo(
- o2.getQualifiedSourceName());
+ return
o1.getQualifiedSourceName().compareTo(o2.getQualifiedSourceName());
}
});
return result;
@@ -656,7 +648,7 @@
* <li><code>List<List<Shape>></code></li>
* </ul>
* </p>
- *
+ *
* @param type a type signature to be parsed
* @return the type object corresponding to the parse type
*/
@@ -802,12 +794,10 @@
if (impl != null) {
jsoSingleImpls.put(intf, impl);
} else {
- throw new InternalCompilerException(
- "Already seen an implementing JSO subtype ("
- + previousType.getName() + ") for interface ("
- + intf.getName() + ") while examining newly-added type
("
- + type.getName() + "). This is a bug in "
- + "JSORestrictionsChecker.");
+ throw new InternalCompilerException("Already seen an
implementing JSO subtype ("
+ + previousType.getName() + ") for interface (" +
intf.getName()
+ + ") while examining newly-added type (" + type.getName()
+ "). This is a bug in "
+ + "JSORestrictionsChecker.");
}
}
}
@@ -818,8 +808,7 @@
* Determines whether both classes A and B share a common superclass
which
* fully implements the given interface.
*/
- private JClassType findFullyImplementingBase(JClassType intf, JClassType
a,
- JClassType b) {
+ private JClassType findFullyImplementingBase(JClassType intf, JClassType
a, JClassType b) {
JClassType common = findNearestCommonBase(a, b);
if (classFullyImplements(common, intf)) {
return common;
@@ -849,8 +838,8 @@
return match;
}
- private JType parseImpl(String type) throws NotFoundException,
- ParseException, BadTypeArgsException {
+ private JType parseImpl(String type) throws NotFoundException,
ParseException,
+ BadTypeArgsException {
if (type.endsWith("[]")) {
String remainder = type.substring(0, type.length() - 2);
JType componentType = parseImpl(remainder);
@@ -860,8 +849,7 @@
if (type.endsWith(">")) {
int bracket = type.indexOf('<');
if (bracket == -1) {
- throw new ParseException(
- "Mismatched brackets; expected '<' to match subsequent '>'");
+ throw new ParseException("Mismatched brackets; expected '<' to
match subsequent '>'");
}
// Resolve the raw type.
@@ -877,15 +865,11 @@
// The raw type must be a class or interface
// (not an array or primitive).
//
- throw new BadTypeArgsException(
- "Only classes and interface can be parameterized, so "
- + rawType.getQualifiedSourceName()
- + " cannot be used in this context");
+ throw new BadTypeArgsException("Only classes and interface can be
parameterized, so "
+ + rawType.getQualifiedSourceName() + " cannot be used in this
context");
} else if (rawType.isGenericType() == null) {
- throw new BadTypeArgsException(
- "'"
- + rawType.getQualifiedSourceName()
- + "' is not a generic type; only generic types can be
parameterized");
+ throw new BadTypeArgsException("'" +
rawType.getQualifiedSourceName()
+ + "' is not a generic type; only generic types can be
parameterized");
}
// Resolve each type argument.
@@ -912,17 +896,14 @@
+ "' as a type name (is it fully qualified?)");
}
- private void parseTypeArgComponent(List<JClassType> typeArgList,
- String typeArgComponent) throws NotFoundException, ParseException,
- BadTypeArgsException {
+ private void parseTypeArgComponent(List<JClassType> typeArgList, String
typeArgComponent)
+ throws NotFoundException, ParseException, BadTypeArgsException {
JType typeArg = parseImpl(typeArgComponent);
if (typeArg.isPrimitive() != null) {
// Cannot be primitive.
//
- throw new BadTypeArgsException(
- "Type arguments cannot be primitives, so '"
- + typeArg.getQualifiedSourceName()
- + "' cannot be used in this context");
+ throw new BadTypeArgsException("Type arguments cannot be primitives,
so '"
+ + typeArg.getQualifiedSourceName() + "' cannot be used in this
context");
}
typeArgList.add((JClassType) typeArg);
@@ -932,8 +913,8 @@
* Returns an array of types specified inside of a gwt.typeArgs javadoc
* annotation.
*/
- private JClassType[] parseTypeArgContents(String typeArgContents)
- throws ParseException, NotFoundException, BadTypeArgsException {
+ private JClassType[] parseTypeArgContents(String typeArgContents) throws
ParseException,
+ NotFoundException, BadTypeArgsException {
List<JClassType> typeArgList = new ArrayList<JClassType>();
int start = 0;
@@ -944,8 +925,7 @@
// scan for closing '>' while ignoring commas
for (int depth = 1; depth > 0;) {
if (++offset == length) {
- throw new ParseException(
- "Mismatched brackets; expected '<' to match
subsequent '>'");
+ throw new ParseException("Mismatched brackets; expected '<'
to match subsequent '>'");
}
char ich = typeArgContents.charAt(offset);
=======================================
---
/trunk/dev/core/test/com/google/gwt/dev/javac/TypeOracleMediatorTestBase.java
Fri Jan 7 11:41:50 2011
+++
/trunk/dev/core/test/com/google/gwt/dev/javac/TypeOracleMediatorTestBase.java
Thu Mar 3 06:57:33 2011
@@ -1,12 +1,12 @@
/*
* Copyright 2010 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may
not
* use this file except in compliance with the License. You may obtain a
copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -82,15 +82,14 @@
/**
* Test TypeOracleMediator.
- *
+ *
* NOTE: These tests require the test source code to be on the classpath.
In
* Eclipse, make sure your launch configuration includes the 'core/test'
* directory on the classpath tab.
*/
public abstract class TypeOracleMediatorTestBase extends TestCase {
- protected static abstract class CheckedJavaResource extends
- MutableJavaResource {
+ protected static abstract class CheckedJavaResource extends
MutableJavaResource {
private final String[] shortTypeNames;
public CheckedJavaResource(Class<?> clazz, String... shortTypeNames) {
@@ -154,7 +153,7 @@
* This method is used to pull sample source from inside the test
case. By
* default, return <code>null</code> to indicate that source should be
on
* the classpath.
- *
+ *
* @return
*/
public String getSource() {
@@ -202,8 +201,7 @@
return null;
}
assertNotNull("Make sure your runtime environment includes the
source "
- + "for the testcases on the classpath if this assertion fails",
- source);
+ + "for the testcases on the classpath if this assertion
fails", source);
}
return source + extraSource;
}
@@ -211,9 +209,9 @@
private TypeData[] getTypeData(Class<?> aClass) throws IOException {
List<TypeData> results = new ArrayList<TypeData>();
String packageName = Shared.getPackageName(aClass.getName());
- TypeData newData = new TypeData(packageName, aClass.getSimpleName(),
- aClass.getName().replace(".", "/"), null, getByteCode(aClass),
- System.currentTimeMillis());
+ TypeData newData =
+ new TypeData(packageName, aClass.getSimpleName(),
aClass.getName().replace(".", "/"),
+ null, getByteCode(aClass), System.currentTimeMillis());
results.add(newData);
Class<?>[] subclasses = aClass.getDeclaredClasses();
for (Class<?> subclass : subclasses) {
@@ -232,8 +230,8 @@
assertNotNull(type);
assertEquals("AfterAssimilate", type.getSimpleSourceName());
assertNotNull(type.getSuperclass());
- assertEquals(getPackageName() + ".BeforeAssimilate",
- type.getSuperclass().getQualifiedSourceName());
+ assertEquals(getPackageName() + ".BeforeAssimilate",
type.getSuperclass()
+ .getQualifiedSourceName());
}
};
@@ -256,8 +254,7 @@
};
protected static final CheckedJavaResource CU_BindToTypeScope = new
CheckedJavaResource(
- BindToTypeScope.class, "BindToTypeScope.Object",
- "BindToTypeScope.DerivedObject") {
+
BindToTypeScope.class, "BindToTypeScope.Object", "BindToTypeScope.DerivedObject")
{
@Override
public void check(JClassType type) throws NotFoundException {
@@ -317,14 +314,14 @@
}
};
- protected static final CheckedJavaResource
CU_DeclaresInnerGenericInterface = new CheckedJavaResource(
- DeclaresGenericInnerInterface.class,
- "DeclaresGenericInnerInterface.Inner") {
- @Override
- public void check(JClassType type) throws NotFoundException {
- assertNotNull(type.isGenericType());
- }
- };
+ protected static final CheckedJavaResource
CU_DeclaresInnerGenericInterface =
+ new CheckedJavaResource(DeclaresGenericInnerInterface.class,
+ "DeclaresGenericInnerInterface.Inner") {
+ @Override
+ public void check(JClassType type) throws NotFoundException {
+ assertNotNull(type.isGenericType());
+ }
+ };
protected static final CheckedJavaResource CU_DeclaresInnerGenericType =
new CheckedJavaResource(
DeclaresGenericInnerType.class, "DeclaresGenericInnerType.Inner") {
@@ -350,8 +347,8 @@
}
};
- protected static final CheckedJavaResource CU_Derived = new
CheckedJavaResource(
- Derived.class, "Derived.Nested") {
+ protected static final CheckedJavaResource CU_Derived = new
CheckedJavaResource(Derived.class,
+ "Derived.Nested") {
@Override
public void check(JClassType type) {
if ("Derived".equals(type.getSimpleSourceName())) {
@@ -444,10 +441,8 @@
public void checkInner(JClassType type) {
assertEquals("ExtendsInner", type.getSimpleSourceName());
- assertEquals(getTypeName() + ".ExtendsInner",
- type.getQualifiedSourceName());
- assertEquals(getTypeName(),
- type.getEnclosingType().getQualifiedSourceName());
+ assertEquals(getTypeName() + ".ExtendsInner",
type.getQualifiedSourceName());
+ assertEquals(getTypeName(),
type.getEnclosingType().getQualifiedSourceName());
}
public void checkOuter(JClassType type) {
@@ -456,18 +451,17 @@
JClassType[] nested = type.getNestedTypes();
assertEquals(1, nested.length);
JClassType inner = nested[0];
- assertEquals(getTypeName() + ".ExtendsInner",
- inner.getQualifiedSourceName());
+ assertEquals(getTypeName() + ".ExtendsInner",
inner.getQualifiedSourceName());
}
};
- protected static final CheckedJavaResource
CU_ExtendsParameterizedInterface = new CheckedJavaResource(
- ExtendsParameterizedInterface.class) {
- @Override
- public void check(JClassType type) throws NotFoundException {
- assertNotNull(type.getSuperclass().isParameterized());
- }
- };
+ protected static final CheckedJavaResource
CU_ExtendsParameterizedInterface =
+ new CheckedJavaResource(ExtendsParameterizedInterface.class) {
+ @Override
+ public void check(JClassType type) throws NotFoundException {
+ assertNotNull(type.getSuperclass().isParameterized());
+ }
+ };
protected static final CheckedJavaResource CU_FieldsAndTypes = new
CheckedJavaResource(
Fields.class) {
@@ -485,8 +479,7 @@
JType fieldType;
JArrayType arrayType;
JType componentType;
- final JClassType someType = tio.getType(getPackageName(),
- "DefaultClass");
+ final JClassType someType =
tio.getType(getPackageName(), "DefaultClass");
final JArrayType intArrayType =
tio.getArrayType(JPrimitiveType.INT);
final JArrayType someTypeArrayType = tio.getArrayType(someType);
final JArrayType intArrayArrayType =
tio.getArrayType(intArrayType);
@@ -541,8 +534,7 @@
componentType = arrayType.getComponentType();
assertNotNull(componentType);
assertSame(someType, componentType);
- assertEquals(getPackageName() + ".DefaultClass[]",
- fieldType.getQualifiedSourceName());
+ assertEquals(getPackageName() + ".DefaultClass[]",
fieldType.getQualifiedSourceName());
field = type.getField("intArrayArray");
fieldType = field.getType();
@@ -587,8 +579,7 @@
public void checkInner(JClassType type) {
assertEquals("Inner", type.getSimpleSourceName());
assertEquals(getTypeName() + ".Inner",
type.getQualifiedSourceName());
- assertEquals(getTypeName(),
- type.getEnclosingType().getQualifiedSourceName());
+ assertEquals(getTypeName(),
type.getEnclosingType().getQualifiedSourceName());
}
public void checkOuter(JClassType type) {
@@ -601,8 +592,7 @@
}
};
- protected static final CheckedJavaResource CU_List = new
CheckedJavaResource(
- List.class) {
+ protected static final CheckedJavaResource CU_List = new
CheckedJavaResource(List.class) {
@Override
public void check(JClassType type) throws NotFoundException {
@@ -623,8 +613,7 @@
}
};
- protected static final CheckedJavaResource CU_Object = new
CheckedJavaResource(
- Object.class) {
+ protected static final CheckedJavaResource CU_Object = new
CheckedJavaResource(Object.class) {
@Override
public void check(JClassType type) {
assertEquals("Object", type.getSimpleSourceName());
@@ -640,8 +629,8 @@
}
};
- protected static final CheckedJavaResource CU_OuterInner = new
CheckedJavaResource(
- Outer.class, "Outer.Inner") {
+ protected static final CheckedJavaResource CU_OuterInner = new
CheckedJavaResource(Outer.class,
+ "Outer.Inner") {
@Override
public void check(JClassType type) {
@@ -655,10 +644,8 @@
public void checkInner(JClassType type) {
assertEquals("Inner", type.getSimpleSourceName());
- assertEquals(CU_OuterInner.getTypeName() + ".Inner",
- type.getQualifiedSourceName());
- assertEquals(CU_OuterInner.getTypeName(),
- type.getEnclosingType().getQualifiedSourceName());
+ assertEquals(CU_OuterInner.getTypeName() + ".Inner",
type.getQualifiedSourceName());
+ assertEquals(CU_OuterInner.getTypeName(),
type.getEnclosingType().getQualifiedSourceName());
}
public void checkOuter(JClassType type) {
@@ -667,33 +654,31 @@
JClassType[] nested = type.getNestedTypes();
assertEquals(1, nested.length);
JClassType inner = nested[0];
- assertEquals(CU_OuterInner.getTypeName() + ".Inner",
- inner.getQualifiedSourceName());
+ assertEquals(CU_OuterInner.getTypeName() + ".Inner",
inner.getQualifiedSourceName());
}
};
- protected static final CheckedJavaResource
CU_ReferencesGenericListConstant = new CheckedJavaResource(
- ReferencesGenericListConstant.class) {
- @Override
- public void check(JClassType type) throws NotFoundException {
- assertEquals(getTypeName(), type.getQualifiedSourceName());
- }
- };
-
- protected static final CheckedJavaResource
CU_ReferencesParameterizedTypeBeforeItsGenericFormHasBeenProcessed = new
CheckedJavaResource(
-
ReferencesParameterizedTypeBeforeItsGenericFormHasBeenProcessed.class) {
-
- @Override
- public void check(JClassType type) throws NotFoundException {
-
- JClassType[] intfs = type.getImplementedInterfaces();
- assertEquals(1, intfs.length);
- assertNotNull(intfs[0].isParameterized());
- }
- };
-
- protected static final CheckedJavaResource CU_String = new
CheckedJavaResource(
- String.class) {
+ protected static final CheckedJavaResource
CU_ReferencesGenericListConstant =
+ new CheckedJavaResource(ReferencesGenericListConstant.class) {
+ @Override
+ public void check(JClassType type) throws NotFoundException {
+ assertEquals(getTypeName(), type.getQualifiedSourceName());
+ }
+ };
+
+ protected static final CheckedJavaResource
CU_ReferencesParameterizedTypeBeforeItsGenericFormHasBeenProcessed =
+ new
CheckedJavaResource(ReferencesParameterizedTypeBeforeItsGenericFormHasBeenProcessed.class)
{
+
+ @Override
+ public void check(JClassType type) throws NotFoundException {
+
+ JClassType[] intfs = type.getImplementedInterfaces();
+ assertEquals(1, intfs.length);
+ assertNotNull(intfs[0].isParameterized());
+ }
+ };
+
+ protected static final CheckedJavaResource CU_String = new
CheckedJavaResource(String.class) {
@Override
public void check(JClassType type) {
assertEquals("String", type.getSimpleSourceName());
@@ -709,27 +694,26 @@
}
};
- protected static final CheckedJavaResource CU_Throwable = new
CheckedJavaResource(
- Throwable.class) {
-
- @Override
- public void check(JClassType type) {
- assertEquals("Throwable", type.getSimpleSourceName());
- assertEquals("java.lang.Throwable", type.getQualifiedSourceName());
- }
-
- @Override
- public String getSource() {
- StringBuffer sb = new StringBuffer();
- sb.append("package java.lang;");
- sb.append("public class Throwable { }");
- return sb.toString();
- }
- };
+ protected static final CheckedJavaResource CU_Throwable =
+ new CheckedJavaResource(Throwable.class) {
+
+ @Override
+ public void check(JClassType type) {
+ assertEquals("Throwable", type.getSimpleSourceName());
+ assertEquals("java.lang.Throwable",
type.getQualifiedSourceName());
+ }
+
+ @Override
+ public String getSource() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("package java.lang;");
+ sb.append("public class Throwable { }");
+ return sb.toString();
+ }
+ };
protected static final CheckedJavaResource CU_UnnestedImplementations =
new CheckedJavaResource(
- Implementations.class, "Implementations.OuterImpl",
- "Implementations.InnerImpl") {
+
Implementations.class, "Implementations.OuterImpl", "Implementations.InnerImpl")
{
@Override
public void check(JClassType type) {
if (type.getSimpleSourceName().equals("Implementations")) {
@@ -739,22 +723,17 @@
};
protected static void assertIsAssignable(JClassType from, JClassType to)
{
- assertTrue("'" + from + "' should be assignable to '" + to + "'",
- from.isAssignableTo(to));
- assertTrue("'" + to + "' should be assignable from '" + from + "'",
- to.isAssignableFrom(from));
+ assertTrue("'" + from + "' should be assignable to '" + to + "'",
from.isAssignableTo(to));
+ assertTrue("'" + to + "' should be assignable from '" + from + "'",
to.isAssignableFrom(from));
}
protected static void assertIsNotAssignable(JClassType from, JClassType
to) {
- assertFalse(from + " should not be assignable to " + to,
- from.isAssignableTo(to));
- assertFalse(to + " should not be assignable to " + from,
- to.isAssignableFrom(from));
+ assertFalse(from + " should not be assignable to " + to,
from.isAssignableTo(to));
+ assertFalse(to + " should not be assignable to " + from,
to.isAssignableFrom(from));
}
- protected static void recordAssignability(
- Map<JClassType, Set<JClassType>> assignabilityMap, JClassType from,
- JClassType to) {
+ protected static void recordAssignability(Map<JClassType,
Set<JClassType>> assignabilityMap,
+ JClassType from, JClassType to) {
Set<JClassType> set = assignabilityMap.get(from);
if (set == null) {
set = new HashSet<JClassType>();
@@ -766,10 +745,10 @@
/**
* Public so that this will be initialized before the CUs.
*/
- public final Map<String, CheckedJavaResource> publicTypeNameToTestCupMap
= new HashMap<String, CheckedJavaResource>();
-
- protected CheckedJavaResource CU_ListAsField = new CheckedJavaResource(
- ListAsField.class) {
+ public final Map<String, CheckedJavaResource> publicTypeNameToTestCupMap
=
+ new HashMap<String, CheckedJavaResource>();
+
+ protected CheckedJavaResource CU_ListAsField = new
CheckedJavaResource(ListAsField.class) {
@Override
public void check(JClassType type) throws NotFoundException {
assertNull(type.isGenericType());
@@ -777,8 +756,7 @@
}
};
- protected CheckedJavaResource CU_MethodsAndParams = new
CheckedJavaResource(
- Methods.class) {
+ protected CheckedJavaResource CU_MethodsAndParams = new
CheckedJavaResource(Methods.class) {
@Override
public void check(JClassType type) throws NotFoundException {
@@ -788,8 +766,7 @@
JMethod method;
JType[] thrownTypes;
final JClassType javaLangObject =
tio.findType("java.lang", "Object");
- final JClassType javaLangThrowable = tio.findType("java.lang",
- "Throwable");
+ final JClassType javaLangThrowable =
tio.findType("java.lang", "Throwable");
final JType[] noParamTypes = new JType[0];
method = type.getMethod("returnsInt", noParamTypes);
@@ -822,15 +799,13 @@
assertEquals("overloaded", element.getName());
}
- method = type.getMethod("overloaded", new JType[]{
- JPrimitiveType.INT, javaLangObject});
+ method = type.getMethod("overloaded", new
JType[]{JPrimitiveType.INT, javaLangObject});
assertSame(JPrimitiveType.VOID, method.getReturnType());
thrownTypes = method.getThrows();
assertEquals(1, thrownTypes.length);
assertSame(javaLangThrowable, thrownTypes[0]);
- method = type.getMethod("overloaded", new JType[]{
- JPrimitiveType.INT, JPrimitiveType.CHAR});
+ method = type.getMethod("overloaded", new
JType[]{JPrimitiveType.INT, JPrimitiveType.CHAR});
assertSame(javaLangObject, method.getReturnType());
thrownTypes = method.getThrows();
assertEquals(0, thrownTypes.length);
@@ -853,8 +828,7 @@
public void checkInner(JClassType type) {
assertEquals("InnerInt", type.getSimpleSourceName());
assertEquals(getTypeName() + ".InnerInt",
type.getQualifiedSourceName());
- assertEquals(getTypeName(),
- type.getEnclosingType().getQualifiedSourceName());
+ assertEquals(getTypeName(),
type.getEnclosingType().getQualifiedSourceName());
}
public void checkOuter(JClassType type) {
@@ -892,8 +866,8 @@
* with a HARD -> WEAK map, verify that the entry remains if there is
no
* reference to key, but is deleted when the reference to value is gone
*/
- Map<Integer, Integer> simpleMap = new ReferenceMap(
- AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK, true);
+ Map<Integer, Integer> simpleMap =
+ new ReferenceMap(AbstractReferenceMap.HARD,
AbstractReferenceMap.WEAK, true);
Integer bar = new Integer(42);
simpleMap.put(new Integer(32), bar);
Runtime.getRuntime().gc();
@@ -906,10 +880,9 @@
* with a WEAK -> WEAK map, verify that the entry is gone if there are
no
* references to either the key or the value.
*/
- simpleMap = new ReferenceMap(AbstractReferenceMap.WEAK,
- AbstractReferenceMap.WEAK, true);
- Map<Integer, Integer> reverseMap = new ReferenceMap(
- AbstractReferenceMap.WEAK, AbstractReferenceMap.WEAK, true);
+ simpleMap = new ReferenceMap(AbstractReferenceMap.WEAK,
AbstractReferenceMap.WEAK, true);
+ Map<Integer, Integer> reverseMap =
+ new ReferenceMap(AbstractReferenceMap.WEAK,
AbstractReferenceMap.WEAK, true);
Integer foo = new Integer(32);
bar = new Integer(42);
simpleMap.put(foo, bar);
@@ -944,23 +917,19 @@
JClassType obj = typeOracle.findType(CU_Object.getTypeName());
assertNotNull(obj);
- JClassType inner = typeOracle.findType(CU_OuterInner.getTypeName()
- + ".Inner");
+ JClassType inner = typeOracle.findType(CU_OuterInner.getTypeName()
+ ".Inner");
assertNotNull(inner);
JClassType derived = typeOracle.findType(CU_Derived.getTypeName());
assertNotNull(derived);
- JClassType nested = typeOracle.findType(CU_Derived.getTypeName()
- + ".Nested");
+ JClassType nested = typeOracle.findType(CU_Derived.getTypeName()
+ ".Nested");
assertNotNull(nested);
- JClassType baseIntf = typeOracle.findType(CU_Derived.getPackageName()
- + ".BaseInterface");
+ JClassType baseIntf = typeOracle.findType(CU_Derived.getPackageName()
+ ".BaseInterface");
assertNotNull(baseIntf);
- JClassType derivedIntf =
typeOracle.findType(CU_Derived.getPackageName()
- + ".DerivedInterface");
+ JClassType derivedIntf =
typeOracle.findType(CU_Derived.getPackageName() + ".DerivedInterface");
assertNotNull(derivedIntf);
recordAssignability(assignabilityMap, derivedIntf, baseIntf);
@@ -1028,8 +997,7 @@
assertNull(fieldParamType.getEnclosingType());
JGenericType baseType = fieldParamType.getBaseType();
assertNotNull(baseType);
- assertEquals(CU_ConstrainedList.getTypeName(),
- baseType.getQualifiedSourceName());
+ assertEquals(CU_ConstrainedList.getTypeName(),
baseType.getQualifiedSourceName());
JClassType[] typeArgs = fieldParamType.getTypeArgs();
assertEquals(1, typeArgs.length);
JWildcardType wildcard = typeArgs[0].isWildcard();
@@ -1038,16 +1006,14 @@
assertEquals("Throwable", upperBound.getSimpleSourceName());
}
- public void testConstrainedList() throws TypeOracleException,
IOException,
- InterruptedException {
+ public void testConstrainedList() throws TypeOracleException,
IOException, InterruptedException {
addTestResource(CU_Object);
addTestResource(CU_Throwable);
addTestResource(CU_ConstrainedList);
buildTypeOracle();
- JClassType type =
typeOracle.getType(CU_ConstrainedList.getPackageName()
- + ".ConstrainedList");
+ JClassType type =
typeOracle.getType(CU_ConstrainedList.getPackageName()
+ ".ConstrainedList");
JClassType throwable = typeOracle.getType("java.lang.Throwable");
assertNotNull(throwable);
assertEquals("Throwable", throwable.getSimpleSourceName());
@@ -1097,10 +1063,9 @@
buildTypeOracle();
// Get the types produced by the TypeOracle
- JClassType outer =
typeOracle.getType(CU_GenericOuterInner.getPackageName()
- + ".GenericOuter");
- JClassType inner =
typeOracle.getType(CU_GenericOuterInner.getPackageName()
- + ".GenericOuter.Inner");
+ JClassType outer =
typeOracle.getType(CU_GenericOuterInner.getPackageName() + ".GenericOuter");
+ JClassType inner =
+ typeOracle.getType(CU_GenericOuterInner.getPackageName()
+ ".GenericOuter.Inner");
assertNull(outer.getEnclosingType());
assertEquals(outer, inner.getEnclosingType());
@@ -1119,10 +1084,11 @@
assertEquals(1, bounds.length);
assertEquals(typeOracle.getJavaLangObject(), bounds[0]);
- JClassType extendsOuter =
typeOracle.getType(CU_GenericOuterInner.getPackageName()
- + ".ExtendsGenericOuter");
- JClassType extendsInner =
typeOracle.getType(CU_GenericOuterInner.getPackageName()
- + ".ExtendsGenericOuter.ExtendsInner");
+ JClassType extendsOuter =
+ typeOracle.getType(CU_GenericOuterInner.getPackageName()
+ ".ExtendsGenericOuter");
+ JClassType extendsInner =
+ typeOracle.getType(CU_GenericOuterInner.getPackageName()
+ + ".ExtendsGenericOuter.ExtendsInner");
assertNull(extendsOuter.getEnclosingType());
assertEquals(extendsOuter, extendsInner.getEnclosingType());
@@ -1139,7 +1105,7 @@
* This test fails for OpenJDK compiled classes compared to JDT
classes. The
* reason is that the superclass of this type doesn't contain a type
* signature for OpenJDK byte code.
- *
+ *
* Commenting out this code for the tests: I'm not sure any generators
* depend on this subtle difference.
*/
@@ -1235,8 +1201,7 @@
* created before the type oracle has had a chance to resolve
* CU_DeclaresInnerGenericInterface.
*/
- public void testParameterizedTypeBuildDependencies()
- throws TypeOracleException {
+ public void testParameterizedTypeBuildDependencies() throws
TypeOracleException {
addTestResource(CU_ReferencesParameterizedTypeBeforeItsGenericFormHasBeenProcessed);
// Intentionally omitting the ExtendsParameterizedInterface resource
// addResource(CU_ExtendsParameterizedInterface);
@@ -1251,7 +1216,7 @@
/**
* Test that modifying a type will cause any types that depend on it to
be
* rebuilt by the TypeOracleBuilder during a refresh.
- *
+ *
* @throws UnableToCompleteException
* @throws NotFoundException
* @throws IOException
@@ -1267,7 +1232,8 @@
// Get the types produced by the TypeOracle
JClassType extendsGenericListType =
typeOracle.getType(CU_ExtendsGenericList.getTypeName());
JClassType genericListType =
typeOracle.getType(CU_GenericList.getTypeName());
- JClassType referencesGenericListConstantType =
typeOracle.getType(CU_ReferencesGenericListConstant.getTypeName());
+ JClassType referencesGenericListConstantType =
+ typeOracle.getType(CU_ReferencesGenericListConstant.getTypeName());
/*
* Invalidate CU_GenericList and simulate a refresh. This should cause
@@ -1276,19 +1242,17 @@
CU_GenericList.touch();
buildTypeOracle();
- assertNotSame(genericListType.getQualifiedSourceName() + "; ",
- typeOracle.getType(CU_GenericList.getTypeName()), genericListType);
- assertNotSame(extendsGenericListType.getQualifiedSourceName() + "; ",
- typeOracle.getType(CU_ExtendsGenericList.getTypeName()),
- extendsGenericListType);
+ assertNotSame(genericListType.getQualifiedSourceName() + "; ",
typeOracle
+ .getType(CU_GenericList.getTypeName()), genericListType);
+ assertNotSame(extendsGenericListType.getQualifiedSourceName() + "; ",
typeOracle
+ .getType(CU_ExtendsGenericList.getTypeName()),
extendsGenericListType);
/*
* Make sure that referencing a constant field will cause a type to be
* rebuilt if the constant changes.
*/
-
assertNotSame(referencesGenericListConstantType.getQualifiedSourceName(),
- typeOracle.getType(CU_ReferencesGenericListConstant.getTypeName()),
- referencesGenericListConstantType);
+
assertNotSame(referencesGenericListConstantType.getQualifiedSourceName(),
typeOracle
+ .getType(CU_ReferencesGenericListConstant.getTypeName()),
referencesGenericListConstantType);
}
public void testTypeParams() throws TypeOracleException {
@@ -1298,8 +1262,7 @@
buildTypeOracle();
JClassType[] types = typeOracle.getTypes();
assertEquals(6, types.length);
- JClassType type =
typeOracle.findType(CU_UnnestedImplementations.getTypeName()
- + ".InnerImpl");
+ JClassType type =
typeOracle.findType(CU_UnnestedImplementations.getTypeName()
+ ".InnerImpl");
assertNotNull(type);
JClassType[] interfaces = type.getImplementedInterfaces();
assertEquals(1, interfaces.length);
@@ -1312,7 +1275,7 @@
/**
* Creates a {@link Resource} and adds it the set of resources.
- *
+ *
* @throws UnableToCompleteException
*/
protected void addResource(String qualifiedTypeName, CharSequence
source) {
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors