diff options
author | Yohann Roussel <yroussel@google.com> | 2014-03-19 16:25:37 +0100 |
---|---|---|
committer | Yohann Roussel <yroussel@google.com> | 2014-03-20 15:13:33 +0100 |
commit | 4eceb95409e844fdc33c9c706e1dc307bfd40303 (patch) | |
tree | ee9f4f3fc79f757c79081c336bce4f1782c6ccd8 /jack-tests/tests/com/android/jack/field | |
parent | 3d2402901b1a6462e2cf47a6fd09711f327961c3 (diff) | |
download | toolchain_jack-4eceb95409e844fdc33c9c706e1dc307bfd40303.zip toolchain_jack-4eceb95409e844fdc33c9c706e1dc307bfd40303.tar.gz toolchain_jack-4eceb95409e844fdc33c9c706e1dc307bfd40303.tar.bz2 |
Initial Jack import.
Change-Id: I953cf0a520195a7187d791b2885848ad0d5a9b43
Diffstat (limited to 'jack-tests/tests/com/android/jack/field')
35 files changed, 1292 insertions, 0 deletions
diff --git a/jack-tests/tests/com/android/jack/field/instance001/dx/Tests.java b/jack-tests/tests/com/android/jack/field/instance001/dx/Tests.java new file mode 100644 index 0000000..88b90fa --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance001/dx/Tests.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance001.dx; + +import com.android.jack.field.instance001.jack.Data; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + private Data instance = new Data(); + + @Test + public void test1() { + testOneValue(0); + testOneValue(17); + testOneValue(0); + testOneValue(-1); + testOneValue(Integer.MAX_VALUE); + testOneValue(Integer.MIN_VALUE); + } + + private void testOneValue(int value) { + instance.set(value); + Assert.assertEquals(value, instance.field); + Assert.assertEquals(value, instance.get()); + } + +} diff --git a/jack-tests/tests/com/android/jack/field/instance001/jack/Data.java b/jack-tests/tests/com/android/jack/field/instance001/jack/Data.java new file mode 100644 index 0000000..5300a18 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance001/jack/Data.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance001.jack; + +public class Data { + + public int field; + + public void set(int value) { + field = value; + } + + public int get() { + return field; + } +} diff --git a/jack-tests/tests/com/android/jack/field/instance002/dx/Tests.java b/jack-tests/tests/com/android/jack/field/instance002/dx/Tests.java new file mode 100644 index 0000000..4580446 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance002/dx/Tests.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance002.dx; + +import com.android.jack.field.instance002.jack.Data; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + private Data instance = new Data(); + + @Test + public void test1() { + testOneValue(0); + testOneValue(17); + testOneValue(0); + testOneValue(-1); + testOneValue(Integer.MAX_VALUE); + testOneValue(Integer.MIN_VALUE); + } + + private void testOneValue(int value) { + instance.set(value); + Assert.assertEquals(value, instance.field); + Assert.assertEquals(value, instance.get()); + } + +} diff --git a/jack-tests/tests/com/android/jack/field/instance002/jack/Data.java b/jack-tests/tests/com/android/jack/field/instance002/jack/Data.java new file mode 100644 index 0000000..7df025e --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance002/jack/Data.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance002.jack; + +public class Data { + + public int field; + + public int set(int value) { + return field = value; + } + + public int get() { + return field; + } +} diff --git a/jack-tests/tests/com/android/jack/field/instance003/dx/Tests.java b/jack-tests/tests/com/android/jack/field/instance003/dx/Tests.java new file mode 100644 index 0000000..6b844d6 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance003/dx/Tests.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance003.dx; + +import com.android.jack.field.instance003.jack.Data; + +import junit.framework.Assert; + +import org.junit.Test; + +public class Tests { + + @Test + public void test1() { + Data d = new Data(); + Assert.assertTrue(d.check()); + Assert.assertTrue(d.check2()); + Assert.assertTrue(d.check3()); + Assert.assertTrue(d.check4()); + Assert.assertTrue(d.check5()); + Assert.assertTrue(d.check6()); + } +} diff --git a/jack-tests/tests/com/android/jack/field/instance003/jack/Data.java b/jack-tests/tests/com/android/jack/field/instance003/jack/Data.java new file mode 100644 index 0000000..ad346ea --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance003/jack/Data.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance003.jack; + +import com.android.jack.field.instance003.jack.other.PublicClass; + + +public class Data extends PublicClass { + public boolean f = false; + + public boolean check() { + return !f; + } + + public boolean check2() { + return getI() == 45; + } + + public boolean check3() { + return getS() != 99; + } + + public boolean check4() { + return getS2() != 77; + } + + public boolean check5() { + return super.f; + } + + public boolean check6() { + Data d = this; + return d.b; + } +}
\ No newline at end of file diff --git a/jack-tests/tests/com/android/jack/field/instance003/jack/other/ProtectedClass.java b/jack-tests/tests/com/android/jack/field/instance003/jack/other/ProtectedClass.java new file mode 100644 index 0000000..c69253b --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance003/jack/other/ProtectedClass.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance003.jack.other; + + +class ProtectedClass { + public boolean b = true; + public boolean f = true; + public int i = 45; + public static int s = 99; +} diff --git a/jack-tests/tests/com/android/jack/field/instance003/jack/other/PublicClass.java b/jack-tests/tests/com/android/jack/field/instance003/jack/other/PublicClass.java new file mode 100644 index 0000000..600ef6b --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance003/jack/other/PublicClass.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance003.jack.other; + + +public class PublicClass extends ProtectedClass { + public int i = 42; + public static int s = 77; + + public int getI() { + return super.i; + } + + public int getS() { + return s; + } + + public int getS2() { + return ProtectedClass.s; + } +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/dx/Tests.java b/jack-tests/tests/com/android/jack/field/instance004/dx/Tests.java new file mode 100644 index 0000000..5637968 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/dx/Tests.java @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.dx; + +import com.android.jack.field.instance004.jack.Data; +import com.android.jack.field.instance004.jack.Data10; +import com.android.jack.field.instance004.jack.Data11; +import com.android.jack.field.instance004.jack.Data2; +import com.android.jack.field.instance004.jack.Data3; +import com.android.jack.field.instance004.jack.Data4; +import com.android.jack.field.instance004.jack.Data5; +import com.android.jack.field.instance004.jack.Data6; +import com.android.jack.field.instance004.jack.Data7; +import com.android.jack.field.instance004.jack.Data8; +import com.android.jack.field.instance004.jack.Data9; + +import junit.framework.Assert; + +import org.junit.Test; + +public class Tests { + + @Test + public void test1() { + Data d = new Data(); + Assert.assertEquals(1, d.j); + } + + @Test + public void test2() { + Data2 d = new Data2(); + Assert.assertEquals(1, d.j); + } + + @Test + public void test3() { + Data3 d = new Data3(); + Assert.assertEquals(0, d.j); + } + + @Test + public void test4() { + Data4 d = new Data4(); + Assert.assertEquals(1, d.j); + } + + @Test + public void test5() { + Data5 d = new Data5(); + Assert.assertEquals(1, d.j); + } + + @Test + public void test6() { + Data6 d = new Data6(); + Assert.assertEquals(1, d.j); + } + + @Test + public void test7() { + Data7.Data7Bis d = new Data7.Data7Bis(); + Assert.assertEquals(1, d.k); + } + + @SuppressWarnings("static-access") + @Test + public void test8() { + try { + new Data8().m(); + Assert.fail(); + } catch(NullPointerException npe) { + // Ok + } + } + + @Test + public void test9() { + try { + Data9.m(); + Assert.fail(); + } catch(NullPointerException npe) { + // Ok + } + } + + @Test + public void test10() { + try { + new Data10().m(); + Assert.fail(); + } catch(NullPointerException e) { + // Ok + } + } + + @Test + public void test11() { + Assert.assertEquals(1, new Data11().m()); + } +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data.java new file mode 100644 index 0000000..91ff624 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + +public class Data { + int m() { + return this.i; + } + + public int j = m(); + + final int i = 1; +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data10.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data10.java new file mode 100644 index 0000000..4be45e4 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data10.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + +public class Data10 { + C getC() { + return null; + } + + public int m() { + return getC().i; + } + + public int j = m(); + + final int i = 1; +} + +class C { + final int i = 1; +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data11.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data11.java new file mode 100644 index 0000000..f0e1948 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data11.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + +public class Data11 { + D getD() { + return null; + } + + @SuppressWarnings("static-access") + public int m() { + return getD().i; + } + + public int j = m(); + + final int i = 1; +} + +class D { + static final int i = 1; +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data2.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data2.java new file mode 100644 index 0000000..1bbc177 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data2.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + +public class Data2 { + int m() { + return this.i; + } + + public int j = m(); + + final byte i = 1; +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data3.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data3.java new file mode 100644 index 0000000..7cd3c36 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data3.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + +public class Data3 { + int m() { + return this.i; + } + + public int j = m(); + + final int i = this.k; + + final short k = 1; +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data4.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data4.java new file mode 100644 index 0000000..fde7cef --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data4.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + +public class Data4 { + int m() { + return i; + } + + public int j = m(); + + final int i = 1; +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data5.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data5.java new file mode 100644 index 0000000..7d27ad2 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data5.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + +public class Data5 { + + public static class Data5Bis { + static final int i = 1; + + static { + int lv = i / 0; + } + } + + int m() { + return Data5Bis.i; + } + + public int j = m(); +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data6.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data6.java new file mode 100644 index 0000000..2c4d0e3 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data6.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + + +public class Data6 { + + public static class Data5Bis { + static { + int lv = 0 / 0; + } + + static final int i = 1; + } + + int m() { + return Data6.Data5Bis.i; + } + + public int j = m(); +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data7.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data7.java new file mode 100644 index 0000000..7e0bede --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data7.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + + +public class Data7 { + + public static class Data7Bis { + public int k = i; + } + + static final int i = 1; +} diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data8.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data8.java new file mode 100644 index 0000000..8a526fd --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data8.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + + +public class Data8 { + @SuppressWarnings("null") + public static int m() { + A a = null; + return a.f; + } +} + +class A { + final int f = 1; + static { + int i = 5/0; + } +}
\ No newline at end of file diff --git a/jack-tests/tests/com/android/jack/field/instance004/jack/Data9.java b/jack-tests/tests/com/android/jack/field/instance004/jack/Data9.java new file mode 100644 index 0000000..f9a052d --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance004/jack/Data9.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance004.jack; + +public class Data9 { + public static int m() { + B a = new B(); + return a.b.f; + } +} + +class B { + final int f = 1; + public B b; +}
\ No newline at end of file diff --git a/jack-tests/tests/com/android/jack/field/instance005/jack/InstanceField.java b/jack-tests/tests/com/android/jack/field/instance005/jack/InstanceField.java new file mode 100644 index 0000000..5b3f394 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/instance005/jack/InstanceField.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.instance005.jack; + +public class InstanceField { + public int f01; + public final int f02; + public final int f03 = 3; + + int f11; + final int f12; + final int f13 = 13; + + protected int f21; + protected final int f22; + protected final int f23 = 23; + + @SuppressWarnings("unused") + private int f31; + @SuppressWarnings("unused") + private final int f32; + @SuppressWarnings("unused") + private final int f33 = 33; + + + { + f02=2; + f12=12; + f22=22; + f01++; + f32=32; + } +} diff --git a/jack-tests/tests/com/android/jack/field/static001/dx/Tests.java b/jack-tests/tests/com/android/jack/field/static001/dx/Tests.java new file mode 100644 index 0000000..187cfc7 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static001/dx/Tests.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static001.dx; + +import com.android.jack.field.static001.jack.Data; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + @Test + public void test1() { + testOneValue(0); + testOneValue(17); + testOneValue(0); + testOneValue(-1); + testOneValue(Integer.MAX_VALUE); + testOneValue(Integer.MIN_VALUE); + } + + private void testOneValue(int value) { + Data.set(value); + Assert.assertEquals(value, Data.field); + Assert.assertEquals(value, Data.get()); + } + +} diff --git a/jack-tests/tests/com/android/jack/field/static001/jack/Data.java b/jack-tests/tests/com/android/jack/field/static001/jack/Data.java new file mode 100644 index 0000000..4c53dcd --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static001/jack/Data.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static001.jack; + +public class Data { + + public static int field; + + public static void set(int value) { + field = value; + } + + public static int get() { + return field; + } +} diff --git a/jack-tests/tests/com/android/jack/field/static002/dx/Tests.java b/jack-tests/tests/com/android/jack/field/static002/dx/Tests.java new file mode 100644 index 0000000..f66d010 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static002/dx/Tests.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static002.dx; + +import com.android.jack.field.static002.jack.Data; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + @Test + public void test1() { + Assert.assertEquals(1 , Data.m()); + } +} diff --git a/jack-tests/tests/com/android/jack/field/static002/jack/Data.java b/jack-tests/tests/com/android/jack/field/static002/jack/Data.java new file mode 100644 index 0000000..743b950 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static002/jack/Data.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static002.jack; + +public class Data { + public static int m() { + A a = null; + return a.f; + } +} + +class A { + static final int f = 1; + static { + int i = 5/0; + } +}
\ No newline at end of file diff --git a/jack-tests/tests/com/android/jack/field/static003/jack/StaticField.java b/jack-tests/tests/com/android/jack/field/static003/jack/StaticField.java new file mode 100644 index 0000000..8d8158c --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static003/jack/StaticField.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static003.jack; + +public class StaticField { + public static int f1; + public static final int f2; + public static final int f3 = 4; + + + static { + f2=3; + } +} diff --git a/jack-tests/tests/com/android/jack/field/static004/dx/Tests.java b/jack-tests/tests/com/android/jack/field/static004/dx/Tests.java new file mode 100644 index 0000000..4c9df88 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static004/dx/Tests.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static004.dx; + +import com.android.jack.field.static004.jack.Data1; +import com.android.jack.field.static004.jack.Data2; +import com.android.jack.field.static004.jack.Data3; +import com.android.jack.field.static004.jack.Data4; +import com.android.jack.field.static004.jack.Data5; +import com.android.jack.field.static004.jack.Data6; + +import junit.framework.Assert; + +import org.junit.Test; + +public class Tests { + + @Test + public void test1() { + Assert.assertEquals(1, Data1.I1); + Assert.assertEquals(2, Data1.I2); + Assert.assertEquals(3, Data1.getI3()); + Assert.assertEquals(4, Data1.getI4()); + Assert.assertEquals(4 + 9, Data1.getI5()); + Assert.assertEquals(6, Data1.I6); + Assert.assertEquals(7, Data1.I7, 0.0); + Assert.assertEquals(8.8, Data1.I8, 0.0); + Assert.assertEquals(null, Data1.I9); + } + + @Test + public void test2() { + Assert.assertEquals("I", Data2.I1); + } + + @Test + public void test3() { + Assert.assertEquals(1, Data3.I1); + } + + @Test + public void test4() { + Assert.assertEquals(1, Data4.I1); + Assert.assertEquals(2, Data4.I2); + Assert.assertEquals('r', Data4.getI4()); + Assert.assertEquals(4 + 9, Data4.I5); + Assert.assertEquals(6l, Data1.I6); + Assert.assertEquals(7f, Data1.I7, 0.0); + Assert.assertEquals(8.8, Data1.I8, 0.0); + Assert.assertEquals(null, Data1.I9); + } + + @Test + public void test5() { + Assert.assertEquals(Integer.valueOf(1), Data5.I1); + Assert.assertEquals(Byte.valueOf((byte) 127), Data5.B1); + Assert.assertEquals(Short.valueOf((short) 256), Data5.S1); + Assert.assertEquals(Character.valueOf('c'), Data5.C1); + Assert.assertEquals(Float.valueOf(1.0f), Data5.F1); + Assert.assertEquals(Double.valueOf(2.0), Data5.D1); + Assert.assertEquals(Long.valueOf(1), Data5.L1); + } + + @Test + public void test6() { + Assert.assertEquals(Data6.class, Data6.I1); + } +} diff --git a/jack-tests/tests/com/android/jack/field/static004/jack/Data1.java b/jack-tests/tests/com/android/jack/field/static004/jack/Data1.java new file mode 100644 index 0000000..376beb9 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static004/jack/Data1.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static004.jack; + +public class Data1 { + + public static final int I1 = 1; + public static final int I2 = 2; + static final byte I3 = 3; + protected static final char I4 = 4; + private static final short I5 = 4 + 9; + public static final long I6 = 6; + public static final float I7 = 7; + public static final double I8 = 8.8; + public static final Object I9 = null; + + + public static byte getI3() { + return I3; + } + + public static char getI4() { + return I4; + } + + public static short getI5() { + return I5; + } +} diff --git a/jack-tests/tests/com/android/jack/field/static004/jack/Data2.java b/jack-tests/tests/com/android/jack/field/static004/jack/Data2.java new file mode 100644 index 0000000..f7818a7 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static004/jack/Data2.java @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static004.jack; + +public class Data2 { + + public static final String I1 = "I"; + +} diff --git a/jack-tests/tests/com/android/jack/field/static004/jack/Data3.java b/jack-tests/tests/com/android/jack/field/static004/jack/Data3.java new file mode 100644 index 0000000..99cb332 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static004/jack/Data3.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static004.jack; + +public class Data3 { + + public static final int I1; + + static { + I1 = 1; + } + +} diff --git a/jack-tests/tests/com/android/jack/field/static004/jack/Data4.java b/jack-tests/tests/com/android/jack/field/static004/jack/Data4.java new file mode 100644 index 0000000..9dbb347 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static004/jack/Data4.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static004.jack; + +public class Data4 { + + public static final int I1 = 1; + public static final int I2 = 2; + protected static final char I4 = 'r'; + public static final int I5 = 4 + 9; + public static final long I6 = 6l; + public static final float I7 = 7f; + public static final double I8 = 8.8; + public static final Object I9 = null; + + public static char getI4() { + return I4; + } +} diff --git a/jack-tests/tests/com/android/jack/field/static004/jack/Data5.java b/jack-tests/tests/com/android/jack/field/static004/jack/Data5.java new file mode 100644 index 0000000..7e32372 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static004/jack/Data5.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static004.jack; + +public class Data5 { + + @SuppressWarnings("boxing") + public static final Integer I1 = 1; + + @SuppressWarnings("boxing") + public static final Byte B1 = 127; + + @SuppressWarnings("boxing") + public static final Short S1 = 256; + + @SuppressWarnings("boxing") + public static final Character C1 = 'c'; + + @SuppressWarnings("boxing") + public static final Float F1 = 1.0f; + + @SuppressWarnings("boxing") + public static final Double D1 = 2.0; + + @SuppressWarnings("boxing") + public static final Long L1 = 1l; +} diff --git a/jack-tests/tests/com/android/jack/field/static004/jack/Data6.java b/jack-tests/tests/com/android/jack/field/static004/jack/Data6.java new file mode 100644 index 0000000..ede92ea --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static004/jack/Data6.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static004.jack; + +public class Data6 { + + public static final Class<?> I1 = Data6.class; +} diff --git a/jack-tests/tests/com/android/jack/field/static005/dx/Tests.java b/jack-tests/tests/com/android/jack/field/static005/dx/Tests.java new file mode 100644 index 0000000..5dcd3b4 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static005/dx/Tests.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static005.dx; + +import com.android.jack.field.static005.jack.Data; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + private static final String EXPECTED_1 = "foo1"; + private static final String EXPECTED_2 = "foo2"; + + @Test + public void test1() { + Assert.assertEquals(EXPECTED_1 , Data.getF1()); + Assert.assertEquals(EXPECTED_2 , Data.getF2()); + } +} diff --git a/jack-tests/tests/com/android/jack/field/static005/jack/Data.java b/jack-tests/tests/com/android/jack/field/static005/jack/Data.java new file mode 100644 index 0000000..5dacad2 --- /dev/null +++ b/jack-tests/tests/com/android/jack/field/static005/jack/Data.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.field.static005.jack; + +public class Data { + + static final Object F1 = "foo1"; + static final CharSequence F2 = "foo2"; + + public static String getF1() { + return (String) F1; + } + + public static String getF2() { + return (String) F2; + } + +}
\ No newline at end of file |