[Jastadd] [bug report] two other bugs

From: Na, Hyunik <hina_at_kaist.ac.kr>
Date: Tue, 1 May 2012 00:34:17 +0900

Hello again,

 

Bug.1.

In EnhancedForCodegen.jrag in Java1.5Backend, EnhancedForStmt.createBCode()
contains the following code:

 

-=-=-=

    .

    if (obj.type().isPrimitive()) {

        gen.emitCheckCast(obj.type().boxed());

        .

    } else {

        .

    }

    .

-=-=-=

 

It seems that the condition of the if statement should be

 

           if ( obj.type().isPrimitiveType() ) {

                     assert !obj.type().isUnknown();

                  .

 

or

 

           if ( obj.type() instanceof PrimitiveType ) {

                     .

 

because isPrimitive() is true also for a non-primitive type whose unboxed
type is primitive.

( see the following definition of ReferenceType.isPrimitive() in
AutoBoxing.jrag in Java1.5Frontend:

          eq ReferenceType.isPrimitive() = !unboxed().isUnknown() &&
unboxed().isPrimitive(); )

Because of the isPrimitve(), gen.emitCheckCast is called with the
UnknownType as its argument when

obj.type() is one of Double, Float, Long, Integer, etc.

 

This produces a wrong constant pool entry

 

           const #... = Asciz _at_primitive/Unknown;

 

in the class file for cases such as the following

 

-=-=-= Test.java

public class Test {

  void test( java.util.Set<Long> set ) {

    for ( Long l: set ) ;

  }

}

-=-=-=

 

This problem was observed when compiling

           . com/sun/media/sound/DLSSoundbank.java

           . javax/management/timer/Timer.java

           . sun/security/pkcs11/Config.java

from OpenJDK1.6

 

Bug.2.

When compiling the following code,

 

-=-=-= Test.java

public class Test {

  void test( int i ) {

    int j;

    assert i == (j=3) : (i + "!=" + j);

  }

}

-=-=-=

 

JastAddJ wrongly produces the following error message.

 

-=-=-=

Errors:

Test.java:7,37:

  Semantic Error: Local variable j in not assigned before used

-=-=-=

 

You can easily see that j is definitely assigned before used.

 

Java spec. for definite assignment and DefiniteAssignment.jrag look quite
complicated,

and probably it will take long time for me to understand them and pin-point
the problematic spot in the code.

So, I just report the symptom in this e-mail. J

 

 

( The above example is a lot simplified and looks rather stupid.

The real code in com/sun/java/util/jar/pack/CodingChooser.java is

 

-=-=-=

.

int size = c.getLength(values, start, end);

int size2;

assert(size == (size2=countBytesToSizer(cm, values, start, end))) : (cm+" :
"+size+" != "+size2);

return size;

.

-=-=-=

 

)

 

Please check these.

 

- Hyunik
Received on Mon Apr 30 2012 - 17:34:32 CEST

This archive was generated by hypermail 2.3.0 : Wed Apr 16 2014 - 17:19:06 CEST