Exemplo n.º 1
0
  // See http://code.google.com/p/google-web-toolkit/issues/detail?id=6591
  // Argument names were incorrect in the presence of long/double args
  public void testLongDoubleArgs() {
    CollectClassData cd = collect(LongDoubleArgs.class);
    assertEquals("CollectClassDataTest.LongDoubleArgs", cd.getNestedSourceName());
    List<CollectMethodData> methods = cd.getMethods();
    assertEquals(2, methods.size());
    CollectMethodData method = methods.get(0);
    Type[] argTypes = method.getArgTypes();
    String[] argNames = method.getArgNames();
    assertEquals("<init>", method.getName());
    assertEquals("x", argNames[0]);
    assertEquals("y", argNames[1]);
    assertEquals("z", argNames[2]);
    assertEquals("o", argNames[3]);
    assertEquals("I", argTypes[0].toString());
    assertEquals("J", argTypes[1].toString());
    assertEquals("D", argTypes[2].toString());
    assertEquals("Ljava/lang/Object;", argTypes[3].toString());

    method = methods.get(1);
    argTypes = method.getArgTypes();
    argNames = method.getArgNames();
    assertEquals("longDoubleMethod", method.getName());
    assertEquals("xx", argNames[0]);
    assertEquals("yy", argNames[1]);
    assertEquals("zz", argNames[2]);
    assertEquals("s", argNames[3]);
    assertEquals("I", argTypes[0].toString());
    assertEquals("J", argTypes[1].toString());
    assertEquals("D", argTypes[2].toString());
    assertEquals("Ljava/lang/String;", argTypes[3].toString());
  }
Exemplo n.º 2
0
  public void testTwo() {
    CollectClassData cd = collect(Two.class);
    // Don't check for super bit, as it will depend on the JDK used to compile.
    assertEquals(Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC, cd.getAccess() & ~Opcodes.ACC_SUPER);
    assertEquals(ClassType.Nested, cd.getClassType());
    List<CollectFieldData> fields = cd.getFields();
    assertEquals(2, fields.size());
    CollectFieldData field = fields.get(0);
    assertEquals("field", field.getName());
    assertEquals("Ljava/lang/String;", field.getDesc());
    List<CollectAnnotationData> annotations = field.getAnnotations();
    assertEquals(0, annotations.size());
    field = fields.get(1);
    assertEquals("annotatedField", field.getName());
    assertEquals("Ljava/lang/String;", field.getDesc());
    annotations = field.getAnnotations();
    assertEquals(1, annotations.size());
    AnnotationData annotation = annotations.get(0).getAnnotation();
    assertEquals("Lcom/google/gwt/dev/javac/typemodel/test/TestAnnotation;", annotation.getDesc());
    assertEquals("field", annotation.getValues().get("value"));
    assertEquals(0, cd.getInterfaceInternalNames().length);
    annotations = cd.getAnnotations();
    assertEquals(1, annotations.size());
    annotation = annotations.get(0).getAnnotation();
    assertEquals(
        "Lcom/google/gwt/dev/javac/typemodel/test/PrimitiveValuesAnnotation;",
        annotation.getDesc());
    assertEquals(Byte.valueOf((byte) 42), annotation.getValues().get("b"));
    assertEquals(42, annotation.getValues().get("i"));
    assertEquals("java/lang/Object", cd.getSuperInternalName());
    assertEquals("CollectClassDataTest.Two", cd.getNestedSourceName());

    List<CollectMethodData> methods = cd.getMethods();
    assertEquals(3, methods.size());
    // TODO(jat): Is it safe to assume the order?
    CollectMethodData method = methods.get(0);
    Type[] argTypes = method.getArgTypes();
    String[] argNames = method.getArgNames();
    assertEquals("<init>", method.getName());
    assertEquals(1, argTypes.length);
    assertEquals(1, argNames.length);
    assertEquals(1, method.getArgAnnotations().length);
    assertEquals(0, method.getAnnotations().size());
    assertEquals(0, method.getExceptions().length);

    method = methods.get(1);
    argTypes = method.getArgTypes();
    argNames = method.getArgNames();
    assertEquals("foo", method.getName());
    assertEquals(1, argTypes.length);
    assertEquals("int", argTypes[0].getClassName());
    assertEquals(1, argNames.length);
    assertEquals("a", argNames[0]);
    assertEquals(1, method.getArgAnnotations().length);
    assertEquals(0, method.getArgAnnotations()[0].size());
    assertEquals(1, method.getAnnotations().size());
    assertEquals(1, method.getExceptions().length);

    method = methods.get(2);
    argTypes = method.getArgTypes();
    argNames = method.getArgNames();
    assertEquals("<init>", method.getName());
    assertEquals(2, argTypes.length);
    assertEquals("int", argTypes[0].getClassName());
    assertEquals("java.lang.String", argTypes[1].getClassName());
    assertEquals(2, argNames.length);
    assertEquals("a", argNames[0]);
    assertEquals("b", argNames[1]);
    assertEquals(2, method.getArgAnnotations().length);
    assertEquals(0, method.getArgAnnotations()[0].size());
    assertEquals(0, method.getArgAnnotations()[1].size());
    assertEquals(0, method.getAnnotations().size());
    assertEquals(0, method.getExceptions().length);
  }
Exemplo n.º 3
0
  public void testOne() {
    CollectClassData cd = collect(One.class);
    // Don't check for super bit, as it will depend on the JDK used to compile.
    assertEquals(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, cd.getAccess() & ~Opcodes.ACC_SUPER);
    assertEquals(ClassType.Nested, cd.getClassType());
    assertEquals(0, cd.getFields().size());
    assertEquals(0, cd.getInterfaceInternalNames().length);
    assertEquals(0, cd.getAnnotations().size());
    assertEquals("com/google/gwt/dev/javac/asmbridge/EmptyVisitor", cd.getSuperInternalName());
    assertEquals("CollectClassDataTest.One", cd.getNestedSourceName());

    List<CollectMethodData> methods = cd.getMethods();
    assertEquals(2, methods.size());
    // TODO(jat): Is it safe to assume the implicit constructor is always first?
    CollectMethodData method = methods.get(0);
    Type[] argTypes = method.getArgTypes();
    String[] argNames = method.getArgNames();
    assertEquals("<init>", method.getName());
    assertEquals(0, argTypes.length);
    assertEquals(0, argNames.length);
    assertEquals(0, method.getArgAnnotations().length);
    assertEquals(0, method.getAnnotations().size());
    assertEquals(0, method.getExceptions().length);

    method = methods.get(1);
    argTypes = method.getArgTypes();
    argNames = method.getArgNames();
    assertEquals("visitAnnotation", method.getName());
    assertEquals(2, argTypes.length);
    assertEquals("java.lang.String", argTypes[0].getClassName());
    assertEquals("boolean", argTypes[1].getClassName());
    assertEquals(2, argNames.length);
    assertEquals("desc", argNames[0]);
    assertEquals("visible", argNames[1]);
    assertEquals(2, method.getArgAnnotations().length);
    assertEquals(0, method.getArgAnnotations()[0].size());
    assertEquals(0, method.getArgAnnotations()[1].size());
    // Note that @Override is a source-only annotation
    assertEquals(0, method.getAnnotations().size());
    assertEquals(0, method.getExceptions().length);
  }