Open sergutsan opened 10 years ago
Much simpler way of reproducing this problem:
int a=1;
print (myMethod(a));
String myMethod(int myParameter) {
return myParameter;
}
Simplest code to reproduce issue:
print (myMethod());
String myMethod() {
return;
}
I said "Maybe this is related to the fact the method returns a String?". If the method myMethod returns an int or a double or a class name (regardles of whether the class is defined or undefined), this issue does not replicate ---so it seems it is actually something to do with String.
Update: it happens too with boxed types such as Integer and Double.
Some additional info: Token 'String' is detected as a token of type FUNCTION (same as 'print' or 'println'), I have no idea why but I guess I cannot change it.
PS: While we are this, I wonder what is the rationale behing 'myMethod', ';', and 'Point' being DATA_TYPE.
print (myMethod());
String myMethod() {
return null;
}
class Point {}
The rabbit hole goes deeper. The issue related to String, Integer, etc, but also to the position of the method:
int a = 1;
a = a + 1;
print (myMethod());
myMethod();
String myMethodS() {
return null;
}
Integer myMethodI() {
return null;
}
Double myMethodD() {
return null;
}
Point myMethod() {
return null;
}
class Point {}
int a = 1;
a = a + 1;
print (myMethod());
myMethod();
Point myMethod() {
return null;
}
String myMethodS() {
return null;
}
Integer myMethodI() {
return null;
}
Double myMethodD() {
return null;
}
class Point {}
PS: Any java.lang class seems to be a function: Integer, String, Exception...
java.lang.* classes are tokens of type FUNCTION, and methods that return them sometimes are created as methods out of the main code, but they are never private static methods.
private static Point myMethod() {
return null;
}
String myMethodS() {
return null;
}
and, as we know, they are not even taken out of the main code unless there is another method, i.e.:
int a = 1;
a = a + 1;
print (myMethod());
myMethod();
String myMethodS() {
return null;
}
Integer myMethodI() {
return null;
}
Point myMethod() {
return null;
}
Double myMethodD() {
return null;
}
Exception myMethodEx() {
return null;
}
class Point {}
results in
import java.util.Scanner;
public class tmp
{
private static Scanner scanner=new Scanner(System.in); static{scanner.useDelimiter(System.getPro\
perty("line.separator"));}
public static void main(String[] args)
{
int a = 1;
a = a + 1;
System.out.print (myMethod());
myMethod();
String myMethodS() {
return null;
}
Integer myMethodI() {
return null;
}
} private static Point myMethod() {
return null;
}
Double myMethodD() {
return null;
}
Exception myMethodEx() {
return null;
}
}
class Point {private static Scanner scanner=new Scanner(System.in); static{scanner.useDelimiter(System.getProperty("line.separator"));}}
I thought ';' was a DATA_TYPE, but now it seems it is an IDENTIFIER too. What an API! :-(
Surely related to #5
Java Decaf code
Expected Java Code
Actual Java Code
Maybe this is related to the fact the method returns a String?