langtools/test/tools/javac/assert/Position.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 10 06bc494ca11e
child 2985 f43e1241e7fb
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * @test  /nodynamiccopyright/
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * @bug 4469737
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary Verify the source position for assertions.
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * @author gafter
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * @compile -source 1.4 Position.java
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * @run main Position
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
public class Position {
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
    static public void main(String[] args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
        Position.class.getClassLoader().setClassAssertionStatus("U", true);
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
        new U().main();
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
class U {
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
    void main() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
            assert false; // line 20
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
        } catch (Throwable t) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
            if (t.getStackTrace()[0].getLineNumber() == 20) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
                return; // passed
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
        throw new Error("failed 4469737");
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
}