-
Bug
-
Resolution: Fixed
-
P2
-
6
-
b81
-
generic
-
generic
isNameCompatible doesn't work or has wrong spec.
-------------------
import javax.tools.*;
import java.net.URI;
public class Test {
public static void main( String[] args ){
URI uri = URI.create("file:///path/file.claSS");
SimpleJavaFileObject fo =
new SimpleJavaFileObject( uri, JavaFileObject.Kind.CLASS) {};
boolean rc;
/* This implementation compares <!!the path of its URI!!> to the given simple name */
String simpleName = uri.getPath();
rc = fo.isNameCompatible( simpleName, JavaFileObject.Kind.CLASS );
System.out.println( String.format( "SJFO('%s', %s).isNameCompatible('%s') = %s. Spec says it have to be true",
fo.toUri(), fo.getKind(), simpleName, rc ) );
simpleName = "file";
rc = fo.isNameCompatible( simpleName, JavaFileObject.Kind.CLASS );
System.out.println( String.format( "SJFO('%s', %s).isNameCompatible('%s') = %s. Spec says it have to be false",
fo.toUri(), fo.getKind(), simpleName, rc ) );
fo = new SimpleJavaFileObject( URI.create( "file:///file.class" ), JavaFileObject.Kind.CLASS) {};
simpleName = "file";
rc = fo.isNameCompatible( simpleName, JavaFileObject.Kind.CLASS );
System.out.println( String.format( "SJFO('%s', %s).isNameCompatible('%s') = %s. Spec says it have to be false",
fo.toUri(), fo.getKind(), simpleName, rc ) );
}
}
-------------------
output:
SJFO('file:///path/file.claSS', CLASS).isNameCompatible('/path/file.claSS') = false. Spec says it have to be true
SJFO('file:///path/file.claSS', CLASS).isNameCompatible('file') = false. Spec says it have to be false
SJFO('file:///file.class', CLASS).isNameCompatible('file') = true. Spec says it have to be false
-------------------
import javax.tools.*;
import java.net.URI;
public class Test {
public static void main( String[] args ){
URI uri = URI.create("file:///path/file.claSS");
SimpleJavaFileObject fo =
new SimpleJavaFileObject( uri, JavaFileObject.Kind.CLASS) {};
boolean rc;
/* This implementation compares <!!the path of its URI!!> to the given simple name */
String simpleName = uri.getPath();
rc = fo.isNameCompatible( simpleName, JavaFileObject.Kind.CLASS );
System.out.println( String.format( "SJFO('%s', %s).isNameCompatible('%s') = %s. Spec says it have to be true",
fo.toUri(), fo.getKind(), simpleName, rc ) );
simpleName = "file";
rc = fo.isNameCompatible( simpleName, JavaFileObject.Kind.CLASS );
System.out.println( String.format( "SJFO('%s', %s).isNameCompatible('%s') = %s. Spec says it have to be false",
fo.toUri(), fo.getKind(), simpleName, rc ) );
fo = new SimpleJavaFileObject( URI.create( "file:///file.class" ), JavaFileObject.Kind.CLASS) {};
simpleName = "file";
rc = fo.isNameCompatible( simpleName, JavaFileObject.Kind.CLASS );
System.out.println( String.format( "SJFO('%s', %s).isNameCompatible('%s') = %s. Spec says it have to be false",
fo.toUri(), fo.getKind(), simpleName, rc ) );
}
}
-------------------
output:
SJFO('file:///path/file.claSS', CLASS).isNameCompatible('/path/file.claSS') = false. Spec says it have to be true
SJFO('file:///path/file.claSS', CLASS).isNameCompatible('file') = false. Spec says it have to be false
SJFO('file:///file.class', CLASS).isNameCompatible('file') = true. Spec says it have to be false