The following file produces an error on line 16383, which is a bit wrong. The error is:
javac -g Tree.java
Tree.java:16383: Invalid method declaration; return type required.
^
1 error
-----------------------------------------------------------------------
import java.awt.*;
public class Tree extends Canvas {
private final static int WIDTH = 300;
private final static int HEIGHT = 500;
private final static int BORDER = 5;
private final static int MIDDLE_X = WIDTH / 2;
private final static int MIDDLE_Y = HEIGHT / 2;
private final static int TOP = BORDER;
private final static int BOTTOM = HEIGHT - BORDER;
private final static int LEFT = BORDER;
private final static int RIGHT = WIDTH - BORDER;
private static int[] topX = { MIDDLE_X, LEFT + 30, RIGHT - 30 };
private static int[] topY = { TOP, TOP + 100, TOP + 100 };
private Polygon top;
Tree() {
top = new Polygon();
for (i = 0; i < topX.length; i++)
top.add(topX[i], topY[i]);
}
draw(Graphics g) {
g.drawPolygon(top);
}
}
javac -g Tree.java
Tree.java:16383: Invalid method declaration; return type required.
^
1 error
-----------------------------------------------------------------------
import java.awt.*;
public class Tree extends Canvas {
private final static int WIDTH = 300;
private final static int HEIGHT = 500;
private final static int BORDER = 5;
private final static int MIDDLE_X = WIDTH / 2;
private final static int MIDDLE_Y = HEIGHT / 2;
private final static int TOP = BORDER;
private final static int BOTTOM = HEIGHT - BORDER;
private final static int LEFT = BORDER;
private final static int RIGHT = WIDTH - BORDER;
private static int[] topX = { MIDDLE_X, LEFT + 30, RIGHT - 30 };
private static int[] topY = { TOP, TOP + 100, TOP + 100 };
private Polygon top;
Tree() {
top = new Polygon();
for (i = 0; i < topX.length; i++)
top.add(topX[i], topY[i]);
}
draw(Graphics g) {
g.drawPolygon(top);
}
}
- duplicates
-
JDK-4026170 Invalid line number in compiler errmsg
- Closed
-
JDK-4015402 Error on missing return type or misspelled constructor has bad location.
- Closed
-
JDK-4016657 wrong source line number in error message
- Closed
-
JDK-4026887 Error message always reports the same line number: 16383
- Closed
- relates to
-
JDK-4041346 JAVAC compiler wraps line numbers after 32767
- Closed