Faculty of Information Technology
Software Engineering Group

Opened 10 years ago

Closed 10 years ago

#6 closed defect (fixed)

default values for primitive types

Reported by: kursjan Owned by: Jan Vraný
Priority: major Milestone: milestone:
Component: stx:libjava Keywords: primitive types, default value


Default value for primitive type int is nil. This is bad, zero is expected.

Change History (4)

comment:1 Changed 10 years ago by kursjan

Use case:

Java flushAllJavaResources.
Java release: JavaRelease openJDK6.
Java initialize.
JavaVM initializeVM.    
Java addToClassPath: ((Smalltalk packageDirectoryForPackageId:'stx:libjava') / 'java' / 'libjava-projects/Conversion/bin' ) pathName.
(Java classForName:'StringManipulator') new hashOfHello.
(Java classForName:'StringManipulator') new hashOfHello2.

The results for this two methods differs. First time it is OK, second time it is nil. The results should be the same.

I found out, that the hashCode()I method is called with hash field set to nil. In that case, the logic of hashCode()I method fails and the nil is returned.

Last edited 10 years ago by kursjan (previous) (diff)

comment:2 Changed 10 years ago by Jan Vraný

Just a comment: why not to add a test case (either in smalltalk or jUnit 3.x test case to libjava-tests? It seems better for me (better than adding new Eclipse project directory for just for a simple test class) But maybe I missed something...

comment:3 Changed 10 years ago by kursjan

The new project is not just a simple test class. It is real use case I am dealing while trying to implement automatic cross language object transformations. It was not created in order to simulate this bug. It was created in order to verify my implementation of object transformations.

comment:4 Changed 10 years ago by Jan Vraný

Resolution: fixed
Status: newclosed

Fixed in r908. The problem appears only when using literal string, as the class reader created them directly (i.e., bypassing any Java code) using Java>>as_String:. The method didn't initialize the hash field.

Note: See TracTickets for help on using tickets.