bug with overloaded methods in kjc

Patrick Tullmann tullmann at cs.utah.edu
Tue May 2 14:31:00 PDT 2000


There is a bug in KJC's handing of overloaded methods.  I believe it
only affects methods whose signatures only contain primitive integer
types. (maybe??)  

This is with the KJC included in recent CVS snapshots of Kaffe.
'javac -version' returns:
	version number: 1.4D released on 13/02/2000

The attached test case demonstrates that given three methods:

	put(byte x);
	put(short x);
	put(int x);

And three calls:
	put((byte)0);
	put((short)0);
	put((int)0);

KJC incorrectly generates three calls to put(byte).  Sun's javac and
IBM's jikes generate the correct calls.

-Pat

----- ----- ---- ---  ---  --   -    -      -         -               -
Pat Tullmann                                       tullmann at cs.utah.edu
		     "Forty-Two." -- Deep Thought


/**
 * Demonstrate method overloading bug in KJC.
 */
public class kjcOverloadBug
{
	private int offset;

	public static void main(String[] args)
	{
		kjcOverloadBug o = new kjcOverloadBug();

		o.check();
	}

	public void put(byte x)
	{
		offset+=1;
	}

	public void put(short y)
	{
		offset+=2;
	}

	public void put(int z)
	{
		offset+=4;
	}

	
	public void checkOffset(int supposedToBe)
	{
		if (offset != supposedToBe)
		{
			System.out.println("Offset should be " +supposedToBe+ ", but is " +offset);
			System.exit(11);
		}
		
		System.out.println("Offset is okay (" +offset+ ").");
	}
	
	public void check()
	{
		offset = 0;
		put((byte)0);  // offset += 1
		put((short)0); // offset += 2
		put((int)0);   // offset += 4
		checkOffset(7);
	}
}


More information about the kaffe mailing list