Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#50 classes with special names like "toString"

open
Josson Smith
5
2010-06-11
2010-06-11
Sebastián Gurin
No

bug when classes has names like toString (yes starts with lowercase). Uncommon but happen in mauve java tests suite (they name tests like methods).

package org.sgx.j2s.j2sBugs.specialNames;

import java.util.LinkedList;

/**
* this is a tests suite that shows j2s failing to handle/instantiate classes with special names like toString, and I think
* other names like equals will also be buggy
*
* this will throw a native javascript eception that sais MethodnotFoundException LinkedList.add() method doesn't exists
*
* I think the issue is in the "new org.sgx.j2s.j2sBugs.specialNames.toString()" statement
*
* @author sgurin
*
*/
public class Main {
/**
* a class with an special name
*
*/
public static class toString {
}

public static void main(String[] args) {
LinkedList l = new LinkedList();
l.add(1);
l.add(new org.sgx.j2s.j2sBugs.specialNames.Main.toString());
System.out.println("end");
}

}

Discussion