2007-10-24 21:06:02 +00:00
|
|
|
public class Misc {
|
2008-02-17 20:57:40 +00:00
|
|
|
private static int alpha;
|
|
|
|
private static int beta;
|
|
|
|
private static byte byte1, byte2, byte3;
|
2008-04-01 00:34:57 +00:00
|
|
|
|
2008-02-17 20:57:40 +00:00
|
|
|
private int gamma;
|
2008-04-01 00:34:57 +00:00
|
|
|
private int pajama;
|
|
|
|
private boolean boolean1;
|
|
|
|
private boolean boolean2;
|
|
|
|
private long time;
|
|
|
|
|
|
|
|
public Misc() {
|
2008-04-28 15:53:48 +00:00
|
|
|
expect(! boolean1);
|
|
|
|
expect(! boolean2);
|
2008-04-01 00:34:57 +00:00
|
|
|
|
2008-04-28 15:53:48 +00:00
|
|
|
time = 0xffffffffffffffffL;
|
2008-04-01 00:34:57 +00:00
|
|
|
|
2008-04-28 15:53:48 +00:00
|
|
|
expect(! boolean1);
|
|
|
|
expect(! boolean2);
|
2008-04-01 00:34:57 +00:00
|
|
|
}
|
2008-02-17 20:57:40 +00:00
|
|
|
|
|
|
|
private String foo(String s) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String bar(String s) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static String baz(String s) {
|
|
|
|
return s;
|
|
|
|
}
|
2007-12-16 00:24:15 +00:00
|
|
|
|
2008-02-17 20:57:40 +00:00
|
|
|
private static void expect(boolean v) {
|
|
|
|
if (! v) throw new RuntimeException();
|
|
|
|
}
|
|
|
|
|
|
|
|
private synchronized byte sync() {
|
|
|
|
byte[] array = new byte[123];
|
|
|
|
return array[42];
|
|
|
|
}
|
2008-02-12 00:20:32 +00:00
|
|
|
|
2008-02-17 20:57:40 +00:00
|
|
|
private static synchronized byte syncStatic(boolean throw_) {
|
|
|
|
byte[] array = new byte[123];
|
|
|
|
if (throw_) {
|
|
|
|
throw new RuntimeException();
|
|
|
|
} else {
|
|
|
|
return array[42];
|
|
|
|
}
|
|
|
|
}
|
2008-02-12 00:20:32 +00:00
|
|
|
|
2008-02-17 20:57:40 +00:00
|
|
|
public String toString() {
|
|
|
|
return super.toString();
|
|
|
|
}
|
2007-09-26 23:23:03 +00:00
|
|
|
|
2008-04-30 15:44:17 +00:00
|
|
|
private static int zap() {
|
|
|
|
return 42;
|
|
|
|
}
|
2008-04-28 15:53:48 +00:00
|
|
|
|
2008-04-30 15:44:17 +00:00
|
|
|
private static int zip() {
|
|
|
|
return 5 + zap();
|
|
|
|
}
|
2008-04-28 15:53:48 +00:00
|
|
|
|
2008-05-15 23:19:23 +00:00
|
|
|
private static int zup() {
|
|
|
|
return zap() + 5;
|
|
|
|
}
|
|
|
|
|
2008-05-20 19:11:42 +00:00
|
|
|
private static class Foo {
|
|
|
|
public int a;
|
|
|
|
public int b;
|
|
|
|
public int c;
|
2008-05-20 21:24:10 +00:00
|
|
|
public int[] array;
|
2008-05-20 19:11:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static int bar(int a, int b, int c) {
|
|
|
|
return a + b + c;
|
|
|
|
}
|
|
|
|
|
2008-04-30 15:44:17 +00:00
|
|
|
public static void main(String[] args) {
|
2008-05-20 19:11:42 +00:00
|
|
|
{ Foo foo = new Foo();
|
|
|
|
int x = foo.a + foo.b + foo.c;
|
|
|
|
bar(foo.a, foo.b, foo.c);
|
|
|
|
}
|
|
|
|
|
2008-04-30 17:15:21 +00:00
|
|
|
byte2 = 0;
|
|
|
|
expect(byte2 == 0);
|
|
|
|
|
|
|
|
boolean v = Boolean.valueOf("true");
|
|
|
|
|
|
|
|
ClassLoader.getSystemClassLoader().toString();
|
|
|
|
|
2008-04-30 17:47:25 +00:00
|
|
|
{ Misc m = new Misc();
|
|
|
|
m.toString();
|
|
|
|
|
2008-05-18 03:32:14 +00:00
|
|
|
expect(m.time == 0xffffffffffffffffL);
|
|
|
|
long t = m.time;
|
|
|
|
expect(t == 0xffffffffffffffffL);
|
|
|
|
|
2008-04-30 17:47:25 +00:00
|
|
|
String s = "hello";
|
|
|
|
m.foo(s);
|
|
|
|
m.bar(s);
|
|
|
|
baz(s);
|
|
|
|
|
|
|
|
m.sync();
|
|
|
|
syncStatic(false);
|
|
|
|
try {
|
|
|
|
syncStatic(true);
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
int d = alpha;
|
|
|
|
beta = 42;
|
|
|
|
alpha = 43;
|
|
|
|
int e = beta;
|
|
|
|
int f = alpha;
|
|
|
|
m.gamma = 44;
|
|
|
|
|
|
|
|
expect(beta == 42);
|
|
|
|
expect(alpha == 43);
|
|
|
|
expect(m.gamma == 44);
|
|
|
|
}
|
2008-04-30 17:15:21 +00:00
|
|
|
|
2008-05-15 23:19:23 +00:00
|
|
|
expect(zip() == 47);
|
|
|
|
expect(zup() == 47);
|
2008-04-30 17:15:21 +00:00
|
|
|
|
2008-05-20 19:11:42 +00:00
|
|
|
{
|
|
|
|
Object a = new Object();
|
|
|
|
Object b = new Object();
|
|
|
|
expect(a != b);
|
|
|
|
|
|
|
|
Object c = a;
|
|
|
|
Object d = b;
|
|
|
|
expect(c != d);
|
|
|
|
|
|
|
|
c = (c == a) ? b : a;
|
|
|
|
d = (d == a) ? b : a;
|
|
|
|
|
|
|
|
expect(c != d);
|
|
|
|
}
|
2008-05-20 21:24:10 +00:00
|
|
|
|
|
|
|
{ Foo foo = new Foo();
|
|
|
|
foo.array = new int[3];
|
|
|
|
foo.a = (foo.a + 1) % foo.array.length;
|
|
|
|
}
|
2007-09-24 01:39:03 +00:00
|
|
|
}
|
|
|
|
}
|