diff options
Diffstat (limited to 'jack-tests/tests/com/android/jack/invoke')
32 files changed, 978 insertions, 0 deletions
diff --git a/jack-tests/tests/com/android/jack/invoke/test001/dx/Tests.java b/jack-tests/tests/com/android/jack/invoke/test001/dx/Tests.java new file mode 100644 index 0000000..80e3041 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/dx/Tests.java @@ -0,0 +1,77 @@ +/* + * 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.invoke.test001.dx; + +import com.android.jack.invoke.test001.jack.InvokeClone; +import com.android.jack.invoke.test001.jack.InvokeDirect; +import com.android.jack.invoke.test001.jack.InvokeInterface; +import com.android.jack.invoke.test001.jack.InvokeInterfaceComputationImpl; +import com.android.jack.invoke.test001.jack.InvokeStatic; +import com.android.jack.invoke.test001.jack.InvokeSuper; +import com.android.jack.invoke.test001.jack.InvokeVirtual; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Tests about invoke static. + */ +public class Tests { + + @Test + public void testInvokeStatic() { + Assert.assertEquals(1 + 2, InvokeStatic.invoke001(1, 2)); + Assert.assertEquals(123456789 + 9876543210L, InvokeStatic.invoke002(123456789, 9876543210L)); + } + + @Test + public void testInvokeDirect() { + Assert.assertEquals(1 + 2, new InvokeDirect().invoke001(1, 2)); + Assert.assertEquals(123456789 + 9876543210L, + new InvokeDirect().invoke002(123456789, 9876543210L)); + } + + @Test + public void testInvokeVirtual() { + Assert.assertEquals(1 + 2, new InvokeVirtual().invoke001(1, 2)); + Assert.assertEquals(123456789 + 9876543210L, + new InvokeVirtual().invoke002(123456789, 9876543210L)); + } + + @Test + public void testInvokeInterfaces() { + Assert.assertEquals(1 + 2, + new InvokeInterface().invoke001(new InvokeInterfaceComputationImpl(), 1, 2)); + Assert.assertEquals(123456789 + 9876543210L, new InvokeInterface().invoke002( + new InvokeInterfaceComputationImpl(), 123456789, 9876543210L)); + } + + @Test + public void testInvokeSuper() { + InvokeSuper invokeSuper = new InvokeSuper(); + Assert.assertEquals(111, invokeSuper.get1()); + Assert.assertEquals(112, invokeSuper.get2()); + Assert.assertEquals(123, invokeSuper.get3()); + Assert.assertEquals(24, invokeSuper.get4()); + Assert.assertEquals(124, invokeSuper.get5()); + } + + @Test + public void testInvokeClone() { + Assert.assertEquals(3, InvokeClone.getArray()[2]); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeClone.java b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeClone.java new file mode 100644 index 0000000..8d1296f --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeClone.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.invoke.test001.jack; + +public class InvokeClone { + + public static int[] getArray() { + int []a = new int[] {1,2,3}; + return (a.clone()); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeDirect.java b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeDirect.java new file mode 100644 index 0000000..1c27f82 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeDirect.java @@ -0,0 +1,39 @@ +/* + * 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.invoke.test001.jack; + +/** + * Invoke direct. + */ +public class InvokeDirect { + + private int addInt(int a, int b) { + return (a + b); + } + + private long addLong(long a, long b) { + return (a + b); + } + + public int invoke001(int a, int b) { + return addInt(a, b); + } + + public long invoke002(long a, long b) { + return addLong(a, b); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeInterface.java b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeInterface.java new file mode 100644 index 0000000..7e6d0f1 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeInterface.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.invoke.test001.jack; + +/** + * Invoke interface. + */ +public class InvokeInterface { + + public int invoke001(InvokeInterfaceComputation compute, int a, int b) { + return compute.addInt(a, b); + } + + public long invoke002(InvokeInterfaceComputation compute, long a, long b) { + return compute.addLong(a, b); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeInterfaceComputation.java b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeInterfaceComputation.java new file mode 100644 index 0000000..b5c626d --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeInterfaceComputation.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.invoke.test001.jack; + +public interface InvokeInterfaceComputation { + int addInt(int a, int b); + + long addLong(long a, long b); +} diff --git a/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeInterfaceComputationImpl.java b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeInterfaceComputationImpl.java new file mode 100644 index 0000000..737c523 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeInterfaceComputationImpl.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.invoke.test001.jack; + +public class InvokeInterfaceComputationImpl implements InvokeInterfaceComputation { + @Override + public int addInt(int a, int b) { + return (a + b); + } + + @Override + public long addLong(long a, long b) { + return (a + b); + } +}
\ No newline at end of file diff --git a/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeStatic.java b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeStatic.java new file mode 100644 index 0000000..0f56c82 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeStatic.java @@ -0,0 +1,39 @@ +/* + * 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.invoke.test001.jack; + +/** + * Invoke static. + */ +public class InvokeStatic { + + public static int addInt(int a, int b) { + return (a + b); + } + + public static long addLong(long a, long b) { + return (a + b); + } + + public static int invoke001(int a, int b) { + return addInt(a, b); + } + + public static long invoke002(long a, long b) { + return addLong(a, b); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeSuper.java b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeSuper.java new file mode 100644 index 0000000..d7c5154 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeSuper.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.invoke.test001.jack; + +/** + * Invoke interface. + */ +public class InvokeSuper extends InvokeSuperSuperClass1 { + + @Override + public int get1() { + return 100 + super.get1(); + } + @Override + public int get2() { + return 100 + super.get2(); + } + + @Override + public int get3() { + return 100 + super.get3(); + } + + public int get5() { + return 100 + super.get4(); + } + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeSuperSuperClass1.java b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeSuperSuperClass1.java new file mode 100644 index 0000000..3ad24af --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeSuperSuperClass1.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.invoke.test001.jack; + +/** + * Invoke interface. + */ +public class InvokeSuperSuperClass1 extends InvokeSuperSuperClass2 { + + public int get1() { + return 11; + } + + public int get2() { + return 12; + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeSuperSuperClass2.java b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeSuperSuperClass2.java new file mode 100644 index 0000000..bf8045e --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeSuperSuperClass2.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.invoke.test001.jack; + +/** + * Invoke interface. + */ +public class InvokeSuperSuperClass2 { + + public int get1() { + return 21; + } + + public int get3() { + return 23; + } + + public int get4() { + return 24; + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeVirtual.java b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeVirtual.java new file mode 100644 index 0000000..ed551d4 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test001/jack/InvokeVirtual.java @@ -0,0 +1,39 @@ +/* + * 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.invoke.test001.jack; + +/** + * Invoke virtual. + */ +public class InvokeVirtual { + + public int addInt(int a, int b) { + return (a + b); + } + + public long addLong(long a, long b) { + return (a + b); + } + + public int invoke001(int a, int b) { + return addInt(a, b); + } + + public long invoke002(long a, long b) { + return addLong(a, b); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test002/dx/Tests.java b/jack-tests/tests/com/android/jack/invoke/test002/dx/Tests.java new file mode 100644 index 0000000..ee16482 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test002/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.invoke.test002.dx; + +import com.android.jack.invoke.test002.jack.Data; + +import junit.framework.Assert; + +import org.junit.Test; + +import java.util.Collection; +import java.util.LinkedList; + +public class Tests { + + @Test + public void test001() { + Collection<String> collection = new LinkedList<String>(); + collection.add("toto"); + collection.add("titi"); + Assert.assertEquals(6, Data.max(collection)); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test002/jack/Data.java b/jack-tests/tests/com/android/jack/invoke/test002/jack/Data.java new file mode 100644 index 0000000..d790285 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test002/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.invoke.test002.jack; + +import java.util.Collection; +import java.util.Iterator; + +public class Data { + + public static <T extends Object & Comparable<? super T>> int max( + Collection<? extends T> collection) { + Iterator<? extends T> iterator = collection.iterator(); + return iterator.next().compareTo(iterator.next()); + } + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test003/dx/Tests.java b/jack-tests/tests/com/android/jack/invoke/test003/dx/Tests.java new file mode 100644 index 0000000..436ef68 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test003/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.invoke.test003.dx; + +import com.android.jack.invoke.test003.jack.C; +import com.android.jack.invoke.test003.jack.Data; +import com.android.jack.invoke.test003.jack.sub.B; + +import junit.framework.Assert; + +import org.junit.Test; + +public class Tests { + + @Test + public void test001() { + B b = new B(); + Assert.assertEquals(1, Data.get(b)); + C c = new C(); + Assert.assertEquals(42, c.get()); + Assert.assertEquals(1, c.getSuper()); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test003/jack/C.java b/jack-tests/tests/com/android/jack/invoke/test003/jack/C.java new file mode 100644 index 0000000..98291c3 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test003/jack/C.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.invoke.test003.jack; + +import com.android.jack.invoke.test003.jack.sub.B; + +public class C extends B { + + @Override + public int get() { + return 42; + } + + public int getSuper() { + return super.get(); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test003/jack/Data.java b/jack-tests/tests/com/android/jack/invoke/test003/jack/Data.java new file mode 100644 index 0000000..a570578 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test003/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.invoke.test003.jack; + +import com.android.jack.invoke.test003.jack.sub.B; + +public class Data { + + public static int get(B b) { + return b.get(); + } + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test003/jack/sub/A.java b/jack-tests/tests/com/android/jack/invoke/test003/jack/sub/A.java new file mode 100644 index 0000000..3bb8088 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test003/jack/sub/A.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.invoke.test003.jack.sub; + +class A { + + public int get() { + return 1; + } + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test003/jack/sub/B.java b/jack-tests/tests/com/android/jack/invoke/test003/jack/sub/B.java new file mode 100644 index 0000000..d04199b --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test003/jack/sub/B.java @@ -0,0 +1,21 @@ +/* + * 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.invoke.test003.jack.sub; + +public class B extends A { + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test004/dx/Tests.java b/jack-tests/tests/com/android/jack/invoke/test004/dx/Tests.java new file mode 100644 index 0000000..1fecb05 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test004/dx/Tests.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.invoke.test004.dx; + +import com.android.jack.invoke.test004.jack.A; +import com.android.jack.invoke.test004.jack.B; +import com.android.jack.invoke.test004.jack.Data; + +import junit.framework.Assert; + +import org.junit.Test; + +public class Tests { + + @Test + public void test001() { + Assert.assertEquals(17, Data.get(new A(), new B(), true)); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test004/jack/A.java b/jack-tests/tests/com/android/jack/invoke/test004/jack/A.java new file mode 100644 index 0000000..76cba62 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test004/jack/A.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.invoke.test004.jack; + +public class A implements I { + + @Override + public int get() { + return 17; + } + + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test004/jack/B.java b/jack-tests/tests/com/android/jack/invoke/test004/jack/B.java new file mode 100644 index 0000000..3edc8d3 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test004/jack/B.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.invoke.test004.jack; + +public class B implements I { + + @Override + public int get() { + return 19; + } + + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test004/jack/Data.java b/jack-tests/tests/com/android/jack/invoke/test004/jack/Data.java new file mode 100644 index 0000000..03cee05 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test004/jack/Data.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.invoke.test004.jack; + +public class Data { + + public static <T extends I, E extends I> int get(T t, E e, boolean condition) { + return (condition ? t : e).get(); + } + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test004/jack/I.java b/jack-tests/tests/com/android/jack/invoke/test004/jack/I.java new file mode 100644 index 0000000..875cc64 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test004/jack/I.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.invoke.test004.jack; + +interface I { + + int get(); +} diff --git a/jack-tests/tests/com/android/jack/invoke/test005/dx/Tests.java b/jack-tests/tests/com/android/jack/invoke/test005/dx/Tests.java new file mode 100644 index 0000000..81abf26 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test005/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.invoke.test005.dx; + +import com.android.jack.invoke.test005.jack.Caller; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + @Test + public void test() { + Assert.assertEquals(3, Caller.getValue()); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test005/jack/Caller.java b/jack-tests/tests/com/android/jack/invoke/test005/jack/Caller.java new file mode 100644 index 0000000..9647438 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test005/jack/Caller.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.invoke.test005.jack; + +import com.android.jack.invoke.test005.lib.SubClass; + +public class Caller { + private static SubClass s = new SubClass(); + + public static int getValue() { + return s.m(); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test005/lib/SubClass.java b/jack-tests/tests/com/android/jack/invoke/test005/lib/SubClass.java new file mode 100644 index 0000000..61d36a8 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test005/lib/SubClass.java @@ -0,0 +1,21 @@ +/* + * 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.invoke.test005.lib; + +public class SubClass extends SuperClass { + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test005/lib/SuperClass.java b/jack-tests/tests/com/android/jack/invoke/test005/lib/SuperClass.java new file mode 100644 index 0000000..fb9a465 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test005/lib/SuperClass.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.invoke.test005.lib; + +class SuperClass { + public int m() { + return 3; + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test006/dx/Tests.java b/jack-tests/tests/com/android/jack/invoke/test006/dx/Tests.java new file mode 100644 index 0000000..c576f10 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test006/dx/Tests.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2013 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.invoke.test006.dx; + +import com.android.jack.invoke.test006.jack.B; +import com.android.jack.invoke.test006.jack.Data; + +import org.junit.Assert; +import org.junit.Test; + +public class Tests { + + @Test + public void test() { + Assert.assertEquals(10, Data.getValue(new B())); + } +} diff --git a/jack-tests/tests/com/android/jack/invoke/test006/jack/A.java b/jack-tests/tests/com/android/jack/invoke/test006/jack/A.java new file mode 100644 index 0000000..15ccf0a --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test006/jack/A.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2013 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.invoke.test006.jack; + +public abstract class A implements I { + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test006/jack/B.java b/jack-tests/tests/com/android/jack/invoke/test006/jack/B.java new file mode 100644 index 0000000..30b2efd --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test006/jack/B.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2013 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.invoke.test006.jack; + +public class B extends A { + + @Override + public int getInt() { + return 10; + } + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test006/jack/Data.java b/jack-tests/tests/com/android/jack/invoke/test006/jack/Data.java new file mode 100644 index 0000000..691322d --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test006/jack/Data.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2013 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.invoke.test006.jack; + +public class Data { + + public static int getValue(A a) { + return a.getInt(); + } + +} diff --git a/jack-tests/tests/com/android/jack/invoke/test006/jack/I.java b/jack-tests/tests/com/android/jack/invoke/test006/jack/I.java new file mode 100644 index 0000000..54b2af7 --- /dev/null +++ b/jack-tests/tests/com/android/jack/invoke/test006/jack/I.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2013 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.invoke.test006.jack; + +public interface I { + + public int getInt(); +} |