# Hard-wired use of experimental jack.
# TODO: fix this temporary work-around for lambdas, see b/19467889
export USE_JACK=true
-export JACK_SERVER=false
-export JACK_REPOSITORY="${ANDROID_BUILD_TOP}/prebuilts/sdk/tools/jacks"
-# e.g. /foo/bar/jack-3.10.ALPHA.jar -> 3.10.ALPHA
-export JACK_VERSION="$(find "$JACK_REPOSITORY" -name '*ALPHA*' | sed 's/.*jack-//g' | sed 's/[.]jar//g')"
./default-build "$@" --experimental default-methods
# Hard-wired use of experimental jack.
# TODO: fix this temporary work-around for lambdas, see b/19467889
export USE_JACK=true
-export JACK_SERVER=false
-export JACK_REPOSITORY="${ANDROID_BUILD_TOP}/prebuilts/sdk/tools/jacks"
-# e.g. /foo/bar/jack-3.10.ALPHA.jar -> 3.10.ALPHA
-export JACK_VERSION="$(find "$JACK_REPOSITORY" -name '*ALPHA*' | sed 's/.*jack-//g' | sed 's/[.]jar//g')"
./default-build "$@" --experimental default-methods
# make us exit on a failure
set -e
-# Generate the smali Main.smali file or fail
-${ANDROID_BUILD_TOP}/art/test/utils/python/generate_smali_main.py ./smali
-
-# Should we compile with Java source code. By default we will use Smali.
-USES_JAVA_SOURCE="false"
-if [[ $@ == *"--jvm"* ]]; then
- USES_JAVA_SOURCE="true"
-elif [[ "$USE_JACK" == "true" ]]; then
- if $JACK -D jack.java.source.version=1.8 >& /dev/null; then
- USES_JAVA_SOURCE="true"
- else
- echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2
- fi
+if [[ $@ != *"--jvm"* ]]; then
+ # Don't do anything with jvm
+ # Hard-wired use of experimental jack.
+ # TODO: fix this temporary work-around for default-methods, see b/19467889
+ export USE_JACK=true
fi
-if [[ "$USES_JAVA_SOURCE" == "true" ]]; then
- # We are compiling java code, create it.
- mkdir -p src
- ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src
- # Ignore the smali directory.
- EXTRA_ARGS="--no-smali"
-fi
+# Generate the Main.java file or fail
+${ANDROID_BUILD_TOP}/art/test/utils/python/generate_java_main.py ./src
-./default-build "$@" "$EXTRA_ARGS" --experimental default-methods
+./default-build "$@" --experimental default-methods
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LA;
-.super Ljava/lang/Object;
-.implements LGreeter;
-
-# class A implements Greeter {
-# public String SayHi() {
-# return "Hi ";
-# }
-# }
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public SayHi()Ljava/lang/String;
- .registers 1
-
- const-string v0, "Hi "
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public abstract interface LAttendant;
-.super Ljava/lang/Object;
-
-# public interface Attendant {
-# public default String SayHi() {
-# return "welcome to " + GetPlace();
-# }
-# public default String SayHiTwice() {
-# return SayHi() + SayHi();
-# }
-#
-# public String GetPlace();
-# }
-
-.method public SayHi()Ljava/lang/String;
- .locals 2
- const-string v0, "welcome to "
- invoke-interface {p0}, LAttendant;->GetPlace()Ljava/lang/String;
- move-result-object v1
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
-
-.method public SayHiTwice()Ljava/lang/String;
- .locals 2
- invoke-interface {p0}, LAttendant;->SayHi()Ljava/lang/String;
- move-result-object v0
- invoke-interface {p0}, LAttendant;->SayHi()Ljava/lang/String;
- move-result-object v1
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
-
-.method public abstract GetPlace()Ljava/lang/String;
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LB;
-.super Ljava/lang/Object;
-.implements LGreeter2;
-
-# class B implements Greeter2 {
-# public String SayHi() {
-# return "Hello ";
-# }
-# }
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public SayHi()Ljava/lang/String;
- .registers 1
-
- const-string v0, "Hello "
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LC;
-.super LA;
-
-# class C extends A {
-# public String SayHiTwice() {
-# return "You don't control me";
-# }
-# }
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, LA;-><init>()V
- return-void
-.end method
-
-.method public SayHiTwice()Ljava/lang/String;
- .registers 1
-
- const-string v0, "You don't control me"
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LD;
-.super Ljava/lang/Object;
-.implements LGreeter3;
-
-# class D implements Greeter3 {
-# public String GetName() {
-# return "Alex ";
-# }
-# }
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public GetName()Ljava/lang/String;
- .registers 1
-
- const-string v0, "Alex "
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LE;
-.super LA;
-.implements LGreeter2;
-
-# class E extends A implements Greeter2 {
-# public String SayHi() {
-# return "Hi2 ";
-# }
-# }
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, LA;-><init>()V
- return-void
-.end method
-
-.method public SayHi()Ljava/lang/String;
- .registers 1
-
- const-string v0, "Hi2 "
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public abstract interface LExtension;
-.super Ljava/lang/Object;
-
-# public interface Extension {
-# public default String SayHi() {
-# return "welcome ";
-# }
-# }
-
-.method public SayHi()Ljava/lang/String;
- .locals 1
- const-string v0, "welcome "
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LF;
-.super LA;
-.implements LAttendant;
-
-# class F extends A implements Attendant {
-# public String GetPlace() {
-# return "android";
-# }
-# public String SayHiTwice() {
-# return "We can override both interfaces";
-# }
-# }
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public SayHiTwice()Ljava/lang/String;
- .registers 1
-
- const-string v0, "We can override both interfaces"
- return-object v0
-.end method
-
-.method public GetPlace()Ljava/lang/String;
- .registers 1
- const-string v0, "android"
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LG;
-.super Ljava/lang/Object;
-.implements LAttendant;
-
-# class G implements Attendant {
-# public String GetPlace() {
-# return "android";
-# }
-# }
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public GetPlace()Ljava/lang/String;
- .registers 1
- const-string v0, "android"
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public abstract interface LGreeter;
-.super Ljava/lang/Object;
-
-# public interface Greeter {
-# public String SayHi();
-#
-# public default String SayHiTwice() {
-# return SayHi() + SayHi();
-# }
-# }
-
-.method public abstract SayHi()Ljava/lang/String;
-.end method
-
-.method public SayHiTwice()Ljava/lang/String;
- .locals 2
- invoke-interface {p0}, LGreeter;->SayHi()Ljava/lang/String;
- move-result-object v0
- invoke-interface {p0}, LGreeter;->SayHi()Ljava/lang/String;
- move-result-object v1
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public abstract interface LGreeter2;
-.super Ljava/lang/Object;
-.implements LGreeter;
-
-# public interface Greeter2 extends Greeter {
-# public default String SayHiTwice() {
-# return "I say " + SayHi() + SayHi();
-# }
-# }
-
-.method public SayHiTwice()Ljava/lang/String;
- .locals 3
- const-string v0, "I say "
- invoke-interface {p0}, LGreeter;->SayHi()Ljava/lang/String;
- move-result-object v1
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- invoke-interface {p0}, LGreeter;->SayHi()Ljava/lang/String;
- move-result-object v1
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public abstract interface LGreeter3;
-.super Ljava/lang/Object;
-.implements LGreeter;
-
-# public interface Greeter3 extends Greeter {
-# public String GetName();
-#
-# public default String SayHi() {
-# return "Hello " + GetName();
-# }
-# }
-
-.method public abstract GetName()Ljava/lang/String;
-.end method
-
-.method public SayHi()Ljava/lang/String;
- .locals 2
- const-string v0, "Hello "
- invoke-interface {p0}, LGreeter3;->GetName()Ljava/lang/String;
- move-result-object v1
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LH;
-.super Ljava/lang/Object;
-.implements LExtension;
-
-# class H implements Extension {
-# }
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LI;
-.super LA;
-.implements LGreeter2;
-
-# class I extends A implements Greeter2 {
-# }
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LJ;
-.super LA;
-
-# class J extends A {
-# }
-
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, LA;-><init>()V
- return-void
-.end method
-
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class A implements Greeter {
+ public String SayHi() {
+ return "Hi ";
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+public interface Attendant {
+ public default String SayHi() {
+ return "welcome to " + GetPlace();
+ }
+ public default String SayHiTwice() {
+ return SayHi() + SayHi();
+ }
+ public String GetPlace();
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class B implements Greeter2 {
+ public String SayHi() {
+ return "Hello ";
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class C extends A {
+ public String SayHiTwice() {
+ return "You don't control me";
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class D implements Greeter3 {
+ public String GetName() {
+ return "Alex ";
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class E extends A implements Greeter2 {
+ public String SayHi() {
+ return "Hi2 ";
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+public interface Extension {
+ public default String SayHi() {
+ return "welcome ";
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class F extends A implements Attendant {
+ public String GetPlace() {
+ return "android";
+ }
+ public String SayHiTwice() {
+ return "We can override both interfaces";
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class G implements Attendant {
+ public String GetPlace() {
+ return "android";
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+public interface Greeter {
+ public String SayHi();
+ public default String SayHiTwice() {
+ return SayHi() + SayHi();
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+public interface Greeter2 extends Greeter {
+ public default String SayHiTwice() {
+ return "I say " + SayHi() + SayHi();
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+public interface Greeter3 extends Greeter {
+ public String GetName();
+ public default String SayHi() {
+ return "Hello " + GetName();
+ }
+}
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class H implements Extension { }
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class I extends A implements Greeter2 { }
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class J extends A { }
}
trap 'restore_ulimit' ERR
-mkdir -p ./smali
-
-# Generate the smali files and expected.txt or fail
-./util-src/generate_smali.py ./smali ./expected.txt
-
-# Should we compile with Java source code. By default we will use Smali.
-USES_JAVA_SOURCE="false"
-if [[ $@ == *"--jvm"* ]]; then
- USES_JAVA_SOURCE="true"
-elif [[ $USE_JACK == "true" ]]; then
- if "$JACK" -D jack.java.source.version=1.8 >& /dev/null; then
- USES_JAVA_SOURCE="true"
- else
- echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2
- fi
+if [[ $@ != *"--jvm"* ]]; then
+ # Don't do anything with jvm
+ # Hard-wired use of experimental jack.
+ # TODO: fix this temporary work-around for default-methods, see b/19467889
+ export USE_JACK=true
fi
-if [[ "$USES_JAVA_SOURCE" == "true" ]]; then
- # We are compiling java code, create it.
- mkdir -p src
- ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src
- # Ignore the smali directory.
- EXTRA_ARGS="--no-smali"
-fi
+mkdir -p ./src
+
+# Generate the smali files and expected.txt or fail
+./util-src/generate_java.py ./src ./expected.txt
-./default-build "$@" "$EXTRA_ARGS" --experimental default-methods
+./default-build "$@" --experimental default-methods
# Reset the ulimit back to its initial value
restore_ulimit
# limitations under the License.
"""
-Generate Smali test files for test 961.
+Generate Java test files for test 961.
"""
import os
# every possible interface tree up to 5 layers deep.
MAX_IFACE_DEPTH = 5
-class MainClass(mixins.DumpMixin, mixins.Named, mixins.SmaliFileMixin):
+class MainClass(mixins.DumpMixin, mixins.Named, mixins.JavaFileMixin):
"""
- A Main.smali file containing the Main class and the main function. It will run
+ A Main.java file containing the Main class and the main function. It will run
all the test functions we have.
"""
MAIN_CLASS_TEMPLATE = """{copyright}
-
-.class public LMain;
-.super Ljava/lang/Object;
-
-# class Main {{
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {{p0}}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
+class Main {{
{test_groups}
-
{main_func}
-
-# }}
+}}
"""
MAIN_FUNCTION_TEMPLATE = """
-# public static void main(String[] args) {{
-.method public static main([Ljava/lang/String;)V
- .locals 2
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
-
+ public static void main(String[] args) {{
{test_group_invoke}
-
- return-void
-.end method
-# }}
+ }}
"""
TEST_GROUP_INVOKE_TEMPLATE = """
-# {test_name}();
- invoke-static {{}}, {test_name}()V
+ {test_name}();
"""
def __init__(self):
def __str__(self):
"""
- Print the MainClass smali code.
+ Print the MainClass java code.
"""
all_tests = sorted(self.tests)
test_invoke = ""
test_invoke += self.TEST_GROUP_INVOKE_TEMPLATE.format(test_name=t.get_name())
main_func = self.MAIN_FUNCTION_TEMPLATE.format(test_group_invoke=test_invoke)
- return self.MAIN_CLASS_TEMPLATE.format(copyright = get_copyright("smali"),
+ return self.MAIN_CLASS_TEMPLATE.format(copyright = get_copyright("java"),
test_groups = test_groups,
main_func = main_func)
"""
TEST_FUNCTION_TEMPLATE = """
-# public static void {fname}() {{
-# try {{
-# {farg} v = new {farg}();
-# System.out.printf("%s calls default method on %s\\n",
-# v.CalledClassName(),
-# v.CalledInterfaceName());
-# return;
-# }} catch (Error e) {{
-# e.printStackTrace(System.out);
-# return;
-# }}
-# }}
-.method public static {fname}()V
- .locals 7
- :call_{fname}_try_start
- new-instance v6, L{farg};
- invoke-direct {{v6}}, L{farg};-><init>()V
-
- const/4 v0, 2
- new-array v1,v0, [Ljava/lang/Object;
- const/4 v0, 0
- invoke-virtual {{v6}}, L{farg};->CalledClassName()Ljava/lang/String;
- move-result-object v4
- aput-object v4,v1,v0
-
- sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v3, "%s calls default method on %s\\n"
-
- invoke-virtual {{v6}}, L{farg};->CalledInterfaceName()Ljava/lang/String;
- move-result-object v4
- const/4 v0, 1
- aput-object v4, v1, v0
-
- invoke-virtual {{v2,v3,v1}}, Ljava/io/PrintStream;->printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
- return-void
- :call_{fname}_try_end
- .catch Ljava/lang/Error; {{:call_{fname}_try_start .. :call_{fname}_try_end}} :error_{fname}_start
- :error_{fname}_start
- move-exception v3
- sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;
- invoke-virtual {{v3,v2}}, Ljava/lang/Error;->printStackTrace(Ljava/io/PrintStream;)V
- return-void
-.end method
+ public static void {fname}() {{
+ try {{
+ {farg} v = new {farg}();
+ System.out.printf("%s calls default method on %s\\n",
+ v.CalledClassName(),
+ v.CalledInterfaceName());
+ return;
+ }} catch (Error e) {{
+ e.printStackTrace(System.out);
+ return;
+ }}
+ }}
"""
def __init__(self, farg):
def __str__(self):
"""
- Print the smali code of this function.
+ Print the java code of this function.
"""
return self.TEST_FUNCTION_TEMPLATE.format(fname=self.get_name(), farg=self.farg.get_name())
-class TestClass(mixins.DumpMixin, mixins.Named, mixins.NameComparableMixin, mixins.SmaliFileMixin):
+class TestClass(mixins.DumpMixin, mixins.Named, mixins.NameComparableMixin, mixins.JavaFileMixin):
"""
A class that will be instantiated to test default method resolution order.
"""
TEST_CLASS_TEMPLATE = """{copyright}
-
-.class public L{class_name};
-.super Ljava/lang/Object;
-.implements L{iface_name};
-
-# public class {class_name} implements {iface_name} {{
-# public String CalledClassName() {{
-# return "{tree}";
-# }}
-# }}
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {{p0}}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public CalledClassName()Ljava/lang/String;
- .locals 1
- const-string v0, "{tree}"
- return-object v0
-.end method
+public class {class_name} implements {iface_name} {{
+ public String CalledClassName() {{
+ return "{tree}";
+ }}
+}}
"""
def __init__(self, iface):
def __str__(self):
"""
- Print the smali code of this class.
+ Print the java code of this class.
"""
- return self.TEST_CLASS_TEMPLATE.format(copyright = get_copyright('smali'),
+ return self.TEST_CLASS_TEMPLATE.format(copyright = get_copyright('java'),
iface_name = self.iface.get_name(),
tree = self.get_tree(),
class_name = self.class_name)
-class TestInterface(mixins.DumpMixin, mixins.Named, mixins.NameComparableMixin, mixins.SmaliFileMixin):
+class TestInterface(mixins.DumpMixin, mixins.Named, mixins.NameComparableMixin, mixins.JavaFileMixin):
"""
An interface that will be used to test default method resolution order.
"""
TEST_INTERFACE_TEMPLATE = """{copyright}
-.class public abstract interface L{class_name};
-.super Ljava/lang/Object;
-{implements_spec}
-
-# public interface {class_name} {extends} {ifaces} {{
-# public String CalledClassName();
-.method public abstract CalledClassName()Ljava/lang/String;
-.end method
+public interface {class_name} {extends} {ifaces} {{
+ public String CalledClassName();
{funcs}
-
-# }}
+}}
"""
DEFAULT_FUNC_TEMPLATE = """
-# public default String CalledInterfaceName() {{
-# return "{tree}";
-# }}
-.method public CalledInterfaceName()Ljava/lang/String;
- .locals 1
- const-string v0, "{tree}"
- return-object v0
-.end method
-"""
-
- IMPLEMENTS_TEMPLATE = """
-.implements L{iface_name};
+ public default String CalledInterfaceName() {{
+ return "{tree}";
+ }}
"""
def __init__(self, ifaces, default):
def __str__(self):
"""
- Print the smali code of this interface.
+ Print the java code of this interface.
"""
- s_ifaces = " "
j_ifaces = " "
for i in self.ifaces:
- s_ifaces += self.IMPLEMENTS_TEMPLATE.format(iface_name = i.get_name())
j_ifaces += " {},".format(i.get_name())
j_ifaces = j_ifaces[0:-1]
if self.default:
class_name = self.class_name)
else:
funcs = ""
- return self.TEST_INTERFACE_TEMPLATE.format(copyright = get_copyright('smali'),
- implements_spec = s_ifaces,
+ return self.TEST_INTERFACE_TEMPLATE.format(copyright = get_copyright('java'),
extends = "extends" if len(self.ifaces) else "",
ifaces = j_ifaces,
funcs = funcs,
return mc, classes
def main(argv):
- smali_dir = Path(argv[1])
- if not smali_dir.exists() or not smali_dir.is_dir():
- print("{} is not a valid smali dir".format(smali_dir), file=sys.stderr)
+ java_dir = Path(argv[1])
+ if not java_dir.exists() or not java_dir.is_dir():
+ print("{} is not a valid java dir".format(java_dir), file=sys.stderr)
sys.exit(1)
expected_txt = Path(argv[2])
mainclass, all_files = create_all_test_files()
with expected_txt.open('w') as out:
print(mainclass.get_expected(), file=out)
for f in all_files:
- f.dump(smali_dir)
+ f.dump(java_dir)
if __name__ == '__main__':
main(sys.argv)
# make us exit on a failure
set -e
-# Should we compile with Java source code. By default we will use Smali.
-USES_JAVA_SOURCE="false"
-if [[ $@ == *"--jvm"* ]]; then
- USES_JAVA_SOURCE="true"
-elif [[ "$USE_JACK" == "true" ]]; then
- if $JACK -D jack.java.source.version=1.8 2>/dev/null; then
- USES_JAVA_SOURCE="true"
- else
- echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2
- fi
+if [[ $@ != *"--jvm"* ]]; then
+ # Don't do anything with jvm
+ # Hard-wired use of experimental jack.
+ # TODO: fix this temporary work-around for default-methods, see b/19467889
+ export USE_JACK=true
fi
-if [[ "$USES_JAVA_SOURCE" == "true" ]]; then
- # We are compiling java code, create it.
- mkdir -p src
- ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src
- # Ignore the smali directory.
- EXTRA_ARGS="--no-smali"
-fi
-
-./default-build "$@" "$EXTRA_ARGS" --experimental default-methods
+./default-build "$@" --experimental default-methods
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public class Displayer {
-# static {
-# System.out.println("init");
-# }
-#
-# public Displayer() {
-# System.out.println("constructor");
-# }
-# }
-
-.class public LDisplayer;
-.super Ljava/lang/Object;
-
-.method static constructor <clinit>()V
- .locals 3
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "init"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- return-void
-.end method
-
-.method public constructor <init>()V
- .locals 2
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "constructor"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- return-void
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# class Main {
-# public static void main(String[] args) {
-# System.out.println(iface.SayHi());
-# }
-# }
-.class public LMain;
-.super Ljava/lang/Object;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public static main([Ljava/lang/String;)V
- .locals 2
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
-
- invoke-static {}, Liface;->SayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- return-void
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface iface {
-# public static final Displayer f = new Displayer();
-#
-# public static String SayHi() {
-# return "Hello";
-# }
-# }
-
-.class public abstract interface Liface;
-.super Ljava/lang/Object;
-
-.field public final static f:LDisplayer;
-
-.method static constructor <clinit>()V
- .locals 3
- new-instance v1, LDisplayer;
- invoke-direct {v1}, LDisplayer;-><init>()V
- sput-object v1, Liface;->f:LDisplayer;
- return-void
-.end method
-
-.method public static SayHi()Ljava/lang/String;
- .locals 1
- const-string v0, "Hello"
- return-object v0
-.end method
-
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public class Displayer {
+ static {
+ System.out.println("init");
+ }
+ public Displayer() {
+ System.out.println("constructor");
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface {
+ public static final Displayer f = new Displayer();
+ public static String SayHi() {
+ return "Hello";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+class Main {
+ public static void main(String[] args) {
+ System.out.println(Iface.SayHi());
+ }
+}
# make us exit on a failure
set -e
-# Should we compile with Java source code. By default we will use Smali.
-USES_JAVA_SOURCE="false"
-if [[ $@ == *"--jvm"* ]]; then
- USES_JAVA_SOURCE="true"
-elif [[ "$USE_JACK" == "true" ]]; then
- if $JACK -D jack.java.source.version=1.8 2>/dev/null; then
- USES_JAVA_SOURCE="true"
- else
- echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2
- fi
+if [[ $@ != *"--jvm"* ]]; then
+ # Don't do anything with jvm
+ # Hard-wired use of experimental jack.
+ # TODO: fix this temporary work-around for default-methods, see b/19467889
+ export USE_JACK=true
fi
-if [[ "$USES_JAVA_SOURCE" == "true" ]]; then
- # We are compiling java code, create it.
- mkdir -p src
- ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src
- # Ignore the smali directory.
- EXTRA_ARGS="--no-smali"
-fi
-
-./default-build "$@" "$EXTRA_ARGS" --experimental default-methods
+./default-build "$@" --experimental default-methods
+++ /dev/null
-# /*
-# * Copyright 2015 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.
-# */
-
-.class public LA;
-.super Ljava/lang/Object;
-.implements Liface;
-
-# class A implements iface {
-# }
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# class Main {
-# public static void main(String[] args) {
-# A a = new A();
-# System.out.println(a.SayHi("a string 0",
-# "a string 1",
-# "a string 2",
-# "a string 3",
-# "a string 4",
-# "a string 5",
-# "a string 6",
-# "a string 7",
-# "a string 8",
-# "a string 9"));
-# iface b = (iface)a;
-# System.out.println(b.SayHi("a string 0",
-# "a string 1",
-# "a string 2",
-# "a string 3",
-# "a string 4",
-# "a string 5",
-# "a string 6",
-# "a string 7",
-# "a string 8",
-# "a string 9"));
-# }
-# }
-.class public LMain;
-.super Ljava/lang/Object;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public static main([Ljava/lang/String;)V
- .locals 15
- sget-object v12, Ljava/lang/System;->out:Ljava/io/PrintStream;
-
- new-instance v1, LA;
- invoke-direct {v1}, LA;-><init>()V
- const-string v2, "a string 0"
- const-string v3, "a string 1"
- const-string v4, "a string 2"
- const-string v5, "a string 3"
- const-string v6, "a string 4"
- const-string v7, "a string 5"
- const-string v8, "a string 6"
- const-string v9, "a string 7"
- const-string v10, "a string 8"
- const-string v11, "a string 9"
- invoke-virtual/range {v1 .. v11}, LA;->SayHi(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v12,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-interface/range {v1 .. v11}, Liface;->SayHi(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v12,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- return-void
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface iface {
-# public default String SayHi(String n1,
-# String n2,
-# String n3,
-# String n4,
-# String n5,
-# String n6,
-# String n7,
-# String n8,
-# String n9,
-# String n0) {
-# return "Hello";
-# }
-# }
-
-.class public abstract interface Liface;
-.super Ljava/lang/Object;
-
-.method public SayHi(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
- .locals 1
- const-string v0, "Hello"
- return-object v0
-.end method
-
--- /dev/null
+/*
+ * Copyright 2015 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.
+ */
+class A implements Iface { }
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface {
+ public default String SayHi(String n1,
+ String n2,
+ String n3,
+ String n4,
+ String n5,
+ String n6,
+ String n7,
+ String n8,
+ String n9,
+ String n0) {
+ return "Hello";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+class Main {
+ public static void main(String[] args) {
+ A a = new A();
+ System.out.println(a.SayHi("a string 0",
+ "a string 1",
+ "a string 2",
+ "a string 3",
+ "a string 4",
+ "a string 5",
+ "a string 6",
+ "a string 7",
+ "a string 8",
+ "a string 9"));
+ Iface b = a;
+ System.out.println(b.SayHi("a string 0",
+ "a string 1",
+ "a string 2",
+ "a string 3",
+ "a string 4",
+ "a string 5",
+ "a string 6",
+ "a string 7",
+ "a string 8",
+ "a string 9"));
+ }
+}
}
trap 'restore_ulimit' ERR
-# Generate the smali files and expected.txt or fail
-./util-src/generate_smali.py ./smali ./expected.txt
-
-# Should we compile with Java source code. By default we will use Smali.
-USES_JAVA_SOURCE="false"
-if [[ $@ == *"--jvm"* ]]; then
- USES_JAVA_SOURCE="true"
-elif [[ "$USE_JACK" == "true" ]]; then
- if $JACK -D jack.java.source.version=1.8 2>/dev/null; then
- USES_JAVA_SOURCE="true"
- else
- echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2
- fi
+if [[ $@ != *"--jvm"* ]]; then
+ # Don't do anything with jvm
+ # Hard-wired use of experimental jack.
+ # TODO: fix this temporary work-around for default-methods, see b/19467889
+ export USE_JACK=true
fi
-if [[ "$USES_JAVA_SOURCE" == "true" ]]; then
- # We are compiling java code, create it.
- mkdir -p src
- ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src
- # Ignore the smali directory.
- EXTRA_ARGS="--no-smali"
-fi
+mkdir -p ./src
+
+# Generate the smali files and expected.txt or fail
+./util-src/generate_java.py ./src ./expected.txt
-./default-build "$@" "$EXTRA_ARGS" --experimental default-methods
+./default-build "$@" --experimental default-methods
# Reset the ulimit back to its initial value
restore_ulimit
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# // This class is b/c java does not allow static {} blocks in interfaces.
-# public class Displayer {
-# public Displayer(String type) {
-# System.out.println("initialization of " + type);
-# }
-# public void touch() {
-# return;
-# }
-# }
-
-.class public LDisplayer;
-.super Ljava/lang/Object;
-
-.method public constructor <init>(Ljava/lang/String;)V
- .locals 2
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- const-string v0, "initialization of "
- invoke-virtual {v0, p1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- return-void
-.end method
-
-.method public touch()V
- .locals 0
- return-void
-.end method
-
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+// This class is b/c java does not allow static {} blocks in interfaces.
+public class Displayer {
+ public Displayer(String type) {
+ System.out.println("initialization of " + type);
+ }
+ public void touch() {
+ return;
+ }
+}
# limitations under the License.
"""
-Generate Smali test files for test 964.
+Generate java test files for test 964.
"""
import os
# The max depth the tree can have.
MAX_IFACE_DEPTH = 3
-class MainClass(mixins.DumpMixin, mixins.Named, mixins.SmaliFileMixin):
+class MainClass(mixins.DumpMixin, mixins.Named, mixins.JavaFileMixin):
"""
- A Main.smali file containing the Main class and the main function. It will run
+ A Main.java file containing the Main class and the main function. It will run
all the test functions we have.
"""
MAIN_CLASS_TEMPLATE = """{copyright}
-
-.class public LMain;
-.super Ljava/lang/Object;
-
-# class Main {{
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {{p0}}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
+class Main {{
{test_groups}
-
{main_func}
-
-# }}
+}}
"""
MAIN_FUNCTION_TEMPLATE = """
-# public static void main(String[] args) {{
-.method public static main([Ljava/lang/String;)V
- .locals 2
-
+ public static void main(String[] args) {{
{test_group_invoke}
-
- return-void
-.end method
-# }}
+ }}
"""
TEST_GROUP_INVOKE_TEMPLATE = """
-# {test_name}();
- invoke-static {{}}, {test_name}()V
+ {test_name}();
"""
def __init__(self):
def __str__(self):
"""
- Print the smali code for this test.
+ Print the java code for this test.
"""
all_tests = sorted(self.tests)
test_invoke = ""
test_invoke += self.TEST_GROUP_INVOKE_TEMPLATE.format(test_name=t.get_name())
main_func = self.MAIN_FUNCTION_TEMPLATE.format(test_group_invoke=test_invoke)
- return self.MAIN_CLASS_TEMPLATE.format(copyright = get_copyright('smali'),
+ return self.MAIN_CLASS_TEMPLATE.format(copyright = get_copyright('java'),
test_groups = test_groups,
main_func = main_func)
"""
TEST_FUNCTION_TEMPLATE = """
-# public static void {fname}() {{
-# try {{
-# System.out.println("About to initialize {tree}");
-# {farg} v = new {farg}();
-# System.out.println("Initialized {tree}");
-# v.touchAll();
-# System.out.println("All of {tree} hierarchy initialized");
-# return;
-# }} catch (Error e) {{
-# e.printStackTrace(System.out);
-# return;
-# }}
-# }}
-.method public static {fname}()V
- .locals 7
- :call_{fname}_try_start
- sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v3, "About to initialize {tree}"
- invoke-virtual {{v2, v3}}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- new-instance v6, L{farg};
- invoke-direct {{v6}}, L{farg};-><init>()V
-
- const-string v3, "Initialized {tree}"
- invoke-virtual {{v2, v3}}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-virtual {{v6}}, L{farg};->touchAll()V
-
- const-string v3, "All of {tree} hierarchy initialized"
- invoke-virtual {{v2, v3}}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- return-void
- :call_{fname}_try_end
- .catch Ljava/lang/Error; {{:call_{fname}_try_start .. :call_{fname}_try_end}} :error_{fname}_start
- :error_{fname}_start
- move-exception v3
- sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;
- invoke-virtual {{v3,v2}}, Ljava/lang/Error;->printStackTrace(Ljava/io/PrintStream;)V
- return-void
-.end method
+ public static void {fname}() {{
+ try {{
+ System.out.println("About to initialize {tree}");
+ {farg} v = new {farg}();
+ System.out.println("Initialized {tree}");
+ v.touchAll();
+ System.out.println("All of {tree} hierarchy initialized");
+ return;
+ }} catch (Error e) {{
+ e.printStackTrace(System.out);
+ return;
+ }}
+ }}
"""
OUTPUT_FORMAT = """
def __str__(self):
"""
- Print the smali code for this test function.
+ Print the java code for this test function.
"""
return self.TEST_FUNCTION_TEMPLATE.format(fname=self.get_name(),
farg=self.farg.get_name(),
initialize_output = self.farg.get_initialize_output().strip(),
touch_output = self.farg.get_touch_output().strip())
-class TestClass(mixins.DumpMixin, mixins.Named, mixins.NameComparableMixin, mixins.SmaliFileMixin):
+class TestClass(mixins.DumpMixin, mixins.Named, mixins.NameComparableMixin, mixins.JavaFileMixin):
"""
A class that will be instantiated to test interface initialization order.
"""
TEST_CLASS_TEMPLATE = """{copyright}
-
-.class public L{class_name};
-.super Ljava/lang/Object;
-{implements_spec}
-
-# public class {class_name} implements {ifaces} {{
-#
-# public {class_name}() {{
-# }}
-.method public constructor <init>()V
- .locals 2
- invoke-direct {{p0}}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-# public void marker() {{
-# return;
-# }}
-.method public marker()V
- .locals 0
- return-void
-.end method
-
-# public void touchAll() {{
-.method public touchAll()V
- .locals 2
- sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
- {touch_calls}
- return-void
-.end method
-# }}
-# }}
-"""
-
- IMPLEMENTS_TEMPLATE = """
-.implements L{iface_name};
+public class {class_name} implements {ifaces} {{
+ public void marker() {{
+ return;
+ }}
+
+ public void touchAll() {{
+{touch_calls}
+ }}
+}}
"""
TOUCH_CALL_TEMPLATE = """
-# System.out.println("{class_name} touching {iface_name}");
-# {iface_name}.field.touch();
- const-string v1, "{class_name} touching {iface_name}"
- invoke-virtual {{v0, v1}}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- sget-object v1, L{iface_name};->field:LDisplayer;
- invoke-virtual {{v1}}, LDisplayer;->touch()V
+ System.out.println("{class_name} touching {iface_name}");
+ {iface_name}.field.touch();
"""
TOUCH_OUTPUT_TEMPLATE = """
def __str__(self):
"""
- Print the smali code for this class.
+ Print the java code for this class.
"""
- s_ifaces = '\n'.join(map(lambda a: self.IMPLEMENTS_TEMPLATE.format(iface_name = a.get_name()),
- self.ifaces))
j_ifaces = ', '.join(map(lambda a: a.get_name(), self.ifaces))
touches = '\n'.join(map(lambda a: self.TOUCH_CALL_TEMPLATE.format(class_name = self.class_name,
iface_name = a.get_name()),
self.get_all_interfaces()))
- return self.TEST_CLASS_TEMPLATE.format(copyright = get_copyright('smali'),
- implements_spec = s_ifaces,
+ return self.TEST_CLASS_TEMPLATE.format(copyright = get_copyright('java'),
ifaces = j_ifaces,
class_name = self.class_name,
touch_calls = touches)
-class TestInterface(mixins.DumpMixin, mixins.Named, mixins.NameComparableMixin, mixins.SmaliFileMixin):
+class TestInterface(mixins.DumpMixin, mixins.Named, mixins.NameComparableMixin, mixins.JavaFileMixin):
"""
An interface that will be used to test default method resolution order.
"""
TEST_INTERFACE_TEMPLATE = """{copyright}
-.class public abstract interface L{class_name};
-.super Ljava/lang/Object;
-{implements_spec}
-
-# public interface {class_name} {extends} {ifaces} {{
-# public static final Displayer field = new Displayer("{tree}");
-.field public final static field:LDisplayer;
-
-.method static constructor <clinit>()V
- .locals 3
- const-string v2, "{tree}"
- new-instance v1, LDisplayer;
- invoke-direct {{v1, v2}}, LDisplayer;-><init>(Ljava/lang/String;)V
- sput-object v1, L{class_name};->field:LDisplayer;
- return-void
-.end method
-
-# public void marker();
-.method public abstract marker()V
-.end method
-
+public interface {class_name} {extends} {ifaces} {{
+ public static final Displayer field = new Displayer("{tree}");
+ public void marker();
{funcs}
-
-# }}
+}}
"""
DEFAULT_FUNC_TEMPLATE = """
-# public default void {class_name}_DEFAULT_FUNC() {{
-# return;
-# }}
-.method public {class_name}_DEFAULT_FUNC()V
- .locals 0
- return-void
-.end method
-"""
- IMPLEMENTS_TEMPLATE = """
-.implements L{iface_name};
+ public default void {class_name}_DEFAULT_FUNC() {{ return; }}
"""
OUTPUT_TEMPLATE = "initialization of {tree}"
def __str__(self):
"""
- Print the smali code for this interface.
+ Print the java code for this interface.
"""
- s_ifaces = '\n'.join(map(lambda a: self.IMPLEMENTS_TEMPLATE.format(iface_name = a.get_name()),
- self.ifaces))
j_ifaces = ', '.join(map(lambda a: a.get_name(), self.ifaces))
if self.default:
funcs = self.DEFAULT_FUNC_TEMPLATE.format(class_name = self.class_name)
else:
funcs = ""
- return self.TEST_INTERFACE_TEMPLATE.format(copyright = get_copyright('smali'),
- implements_spec = s_ifaces,
+ return self.TEST_INTERFACE_TEMPLATE.format(copyright = get_copyright('java'),
extends = "extends" if len(self.ifaces) else "",
ifaces = j_ifaces,
funcs = funcs,
return mc, classes
def main(argv):
- smali_dir = Path(argv[1])
- if not smali_dir.exists() or not smali_dir.is_dir():
- print("{} is not a valid smali dir".format(smali_dir), file=sys.stderr)
+ java_dir = Path(argv[1])
+ if not java_dir.exists() or not java_dir.is_dir():
+ print("{} is not a valid java dir".format(java_dir), file=sys.stderr)
sys.exit(1)
expected_txt = Path(argv[2])
mainclass, all_files = create_all_test_files()
with expected_txt.open('w') as out:
print(mainclass.get_expected(), file=out)
for f in all_files:
- f.dump(smali_dir)
+ f.dump(java_dir)
if __name__ == '__main__':
main(sys.argv)
# make us exit on a failure
set -e
-# Should we compile with Java source code. By default we will use Smali.
-USES_JAVA_SOURCE="false"
-if [[ $@ == *"--jvm"* ]]; then
- USES_JAVA_SOURCE="true"
-elif [[ "$USE_JACK" == "true" ]]; then
- if $JACK -D jack.java.source.version=1.8 2>/dev/null; then
- USES_JAVA_SOURCE="true"
- else
- echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2
- fi
+if [[ $@ != *"--jvm"* ]]; then
+ # Don't do anything with jvm
+ # Hard-wired use of experimental jack.
+ # TODO: fix this temporary work-around for default-methods, see b/19467889
+ export USE_JACK=true
fi
-if [[ "$USES_JAVA_SOURCE" == "true" ]]; then
- # We are compiling Java code, create it.
- mkdir -p src
- mkdir -p src2
- ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src
- # Move build-src to src and the src copies to src2. This is needed because of
- # how our default build script works and we wanted the java and smali code
- # to be the same in the smali files.
- for f in `find ./build-src -type f -name "*.java" | xargs -i basename \{\}`; do
- mv ./src/$f ./src2/$f
- mv ./build-src/$f ./src/$f
- done
- # Ignore the smali directory.
- EXTRA_ARGS="--no-smali"
-fi
-
-./default-build "$@" "$EXTRA_ARGS" --experimental default-methods
+./default-build "$@" --experimental default-methods
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface Iface {
-# public default String sayHi() {
-# return "Hello";
-# }
-#
-# public default void verificationSoftFail() {
-# Statics.nonexistantFunction();
-# }
-# }
-
-.class public abstract interface LIface;
-.super Ljava/lang/Object;
-
-.method public sayHi()Ljava/lang/String;
- .locals 1
- const-string v0, "Hello"
- return-object v0
-.end method
-
-.method public verificationSoftFail()V
- .locals 1
- invoke-static {}, LStatics;->nonexistantFunction()V
- return-void
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# class Main implements Iface {
-# public static void main(String[] args) {
-# System.out.println("Create Main instance");
-# Main m = new Main();
-# System.out.println("Calling functions on concrete Main");
-# callMain(m);
-# System.out.println("Calling functions on interface Iface");
-# callIface(m);
-# }
-#
-# public static void callMain(Main m) {
-# System.out.println("Calling verifiable function on Main");
-# System.out.println(m.sayHi());
-# System.out.println("Calling unverifiable function on Main");
-# try {
-# m.verificationSoftFail();
-# System.out.println("Unexpected no error Thrown on Main");
-# } catch (NoSuchMethodError e) {
-# System.out.println("Expected NSME Thrown on Main");
-# } catch (Throwable e) {
-# System.out.println("Unexpected Error Thrown on Main");
-# e.printStackTrace(System.out);
-# }
-# System.out.println("Calling verifiable function on Main");
-# System.out.println(m.sayHi());
-# return;
-# }
-#
-# public static void callIface(Iface m) {
-# System.out.println("Calling verifiable function on Iface");
-# System.out.println(m.sayHi());
-# System.out.println("Calling unverifiable function on Iface");
-# try {
-# m.verificationSoftFail();
-# System.out.println("Unexpected no error Thrown on Iface");
-# } catch (NoSuchMethodError e) {
-# System.out.println("Expected NSME Thrown on Iface");
-# } catch (Throwable e) {
-# System.out.println("Unexpected Error Thrown on Iface");
-# e.printStackTrace(System.out);
-# }
-# System.out.println("Calling verifiable function on Iface");
-# System.out.println(m.sayHi());
-# return;
-# }
-# }
-
-.class public LMain;
-.super Ljava/lang/Object;
-.implements LIface;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public static main([Ljava/lang/String;)V
- .locals 3
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
-
- const-string v0, "Create Main instance"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- new-instance v2, LMain;
- invoke-direct {v2}, LMain;-><init>()V
-
- const-string v0, "Calling functions on concrete Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- invoke-static {v2}, LMain;->callMain(LMain;)V
-
- const-string v0, "Calling functions on interface Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- invoke-static {v2}, LMain;->callIface(LIface;)V
-
- return-void
-.end method
-
-.method public static callIface(LIface;)V
- .locals 3
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "Calling verifiable function on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-interface {p0}, LIface;->sayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Calling unverifiable function on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- :try_start
- invoke-interface {p0}, LIface;->verificationSoftFail()V
-
- const-string v0, "Unexpected no error Thrown on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- goto :error_end
- :try_end
- .catch Ljava/lang/NoSuchMethodError; {:try_start .. :try_end} :NSME_error_start
- .catch Ljava/lang/Throwable; {:try_start .. :try_end} :other_error_start
- :NSME_error_start
- const-string v0, "Expected NSME Thrown on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :other_error_start
- move-exception v2
- const-string v0, "Unexpected Error Thrown on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- invoke-virtual {v2,v1}, Ljava/lang/Throwable;->printStackTrace(Ljava/io/PrintStream;)V
- goto :error_end
- :error_end
- const-string v0, "Calling verifiable function on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-interface {p0}, LIface;->sayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- return-void
-.end method
-
-.method public static callMain(LMain;)V
- .locals 3
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "Calling verifiable function on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-virtual {p0}, LMain;->sayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Calling unverifiable function on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- :try_start
- invoke-virtual {p0}, LMain;->verificationSoftFail()V
-
- const-string v0, "Unexpected no error Thrown on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- goto :error_end
- :try_end
- .catch Ljava/lang/NoSuchMethodError; {:try_start .. :try_end} :NSME_error_start
- .catch Ljava/lang/Throwable; {:try_start .. :try_end} :other_error_start
- :NSME_error_start
- const-string v0, "Expected NSME Thrown on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :other_error_start
- move-exception v2
- const-string v0, "Unexpected Error Thrown on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- invoke-virtual {v2,v1}, Ljava/lang/Throwable;->printStackTrace(Ljava/io/PrintStream;)V
- goto :error_end
- :error_end
- const-string v0, "Calling verifiable function on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-virtual {p0}, LMain;->sayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- return-void
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# class Statics {
-# // public static void nonexistantFunction() {
-# // System.out.println("I don't exist");
-# // }
-# }
-#
-.class public LStatics;
-.super Ljava/lang/Object;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface {
+ public default String sayHi() {
+ return "Hello";
+ }
+ public default void verificationSoftFail() {
+ Statics.nonexistantFunction();
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+class Main implements Iface {
+ public static void main(String[] args) {
+ System.out.println("Create Main instance");
+ Main m = new Main();
+ System.out.println("Calling functions on concrete Main");
+ callMain(m);
+ System.out.println("Calling functions on interface Iface");
+ callIface(m);
+ }
+
+ public static void callMain(Main m) {
+ System.out.println("Calling verifiable function on Main");
+ System.out.println(m.sayHi());
+ System.out.println("Calling unverifiable function on Main");
+ try {
+ m.verificationSoftFail();
+ System.out.println("Unexpected no error Thrown on Main");
+ } catch (NoSuchMethodError e) {
+ System.out.println("Expected NSME Thrown on Main");
+ } catch (Throwable e) {
+ System.out.println("Unexpected Error Thrown on Main");
+ e.printStackTrace(System.out);
+ }
+ System.out.println("Calling verifiable function on Main");
+ System.out.println(m.sayHi());
+ return;
+ }
+
+ public static void callIface(Iface m) {
+ System.out.println("Calling verifiable function on Iface");
+ System.out.println(m.sayHi());
+ System.out.println("Calling unverifiable function on Iface");
+ try {
+ m.verificationSoftFail();
+ System.out.println("Unexpected no error Thrown on Iface");
+ } catch (NoSuchMethodError e) {
+ System.out.println("Expected NSME Thrown on Iface");
+ } catch (Throwable e) {
+ System.out.println("Unexpected Error Thrown on Iface");
+ e.printStackTrace(System.out);
+ }
+ System.out.println("Calling verifiable function on Iface");
+ System.out.println(m.sayHi());
+ return;
+ }
+}
class Statics {
public static void nonexistantFunction() {
- System.out.println("I don't exist");
+ System.out.println("I don't exist");
}
}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+class Statics {
+ // public static void nonexistantFunction() {
+ // System.out.println("I don't exist");
+ // }
+}
# make us exit on a failure
set -e
-# TODO: Support running with jack.
-
-if [[ $@ == *"--jvm"* ]]; then
- # Build the Java files if we are running a --jvm test
- mkdir -p src
- mkdir -p classes
- ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src
- # Build with the non-conflicting version
- ${JAVAC} -implicit:none -d classes src/Iface.java build-src/Iface2.java src/Main.java
- rm classes/Iface2.class
- # Build with the conflicting version
- ${JAVAC} -implicit:none -cp classes -d classes src/Iface2.java
-else
- ./default-build "$@" --experimental default-methods
+if [[ $@ != *"--jvm"* ]]; then
+ # Don't do anything with jvm
+ # Hard-wired use of experimental jack.
+ # TODO: fix this temporary work-around for default-methods, see b/19467889
+ export USE_JACK=true
fi
+
+./default-build "$@" --experimental default-methods
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface Iface {
-# public default String sayHi() {
-# return "Hi";
-# }
-# public default String charge() {
-# return "CHARGE";
-# }
-# }
-
-.class public abstract interface LIface;
-.super Ljava/lang/Object;
-
-.method public sayHi()Ljava/lang/String;
- .locals 1
- const-string v0, "Hi"
- return-object v0
-.end method
-
-.method public charge()Ljava/lang/String;
- .locals 1
- const-string v0, "CHARGE"
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface Iface2 {
-# public default String sayHi() {
-# return "hello";
-# }
-# }
-
-.class public abstract interface LIface2;
-.super Ljava/lang/Object;
-
-.method public sayHi()Ljava/lang/String;
- .locals 1
- const-string v0, "hello"
- return-object v0
-.end method
-
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# class Main implements Iface, Iface2 {
-# public static void main(String[] args) {
-# System.out.println("Create Main instance");
-# Main m = new Main();
-# System.out.println("Calling functions on concrete Main");
-# callMain(m);
-# System.out.println("Calling functions on interface Iface");
-# callIface(m);
-# System.out.println("Calling functions on interface Iface2");
-# callIface2(m);
-# }
-#
-# public static void callMain(Main m) {
-# System.out.println("Calling non-conflicting function on Main");
-# System.out.println(m.charge());
-# System.out.println("Calling conflicting function on Main");
-# try {
-# System.out.println(m.sayHi());
-# System.out.println("Unexpected no error Thrown on Main");
-# } catch (AbstractMethodError e) {
-# System.out.println("Unexpected AME Thrown on Main");
-# } catch (IncompatibleClassChangeError e) {
-# System.out.println("Expected ICCE Thrown on Main");
-# }
-# System.out.println("Calling non-conflicting function on Main");
-# System.out.println(m.charge());
-# return;
-# }
-#
-# public static void callIface(Iface m) {
-# System.out.println("Calling non-conflicting function on Iface");
-# System.out.println(m.charge());
-# System.out.println("Calling conflicting function on Iface");
-# try {
-# System.out.println(m.sayHi());
-# System.out.println("Unexpected no error Thrown on Iface");
-# } catch (AbstractMethodError e) {
-# System.out.println("Unexpected AME Thrown on Iface");
-# } catch (IncompatibleClassChangeError e) {
-# System.out.println("Expected ICCE Thrown on Iface");
-# }
-# System.out.println("Calling non-conflicting function on Iface");
-# System.out.println(m.charge());
-# return;
-# }
-#
-# public static void callIface2(Iface2 m) {
-# System.out.println("Calling conflicting function on Iface2");
-# try {
-# System.out.println(m.sayHi());
-# System.out.println("Unexpected no error Thrown on Iface2");
-# } catch (AbstractMethodError e) {
-# System.out.println("Unexpected AME Thrown on Iface2");
-# } catch (IncompatibleClassChangeError e) {
-# System.out.println("Expected ICCE Thrown on Iface2");
-# }
-# return;
-# }
-# }
-
-.class public LMain;
-.super Ljava/lang/Object;
-.implements LIface;
-.implements LIface2;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public static main([Ljava/lang/String;)V
- .locals 3
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
-
- const-string v0, "Create Main instance"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- new-instance v2, LMain;
- invoke-direct {v2}, LMain;-><init>()V
-
- const-string v0, "Calling functions on concrete Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- invoke-static {v2}, LMain;->callMain(LMain;)V
-
- const-string v0, "Calling functions on interface Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- invoke-static {v2}, LMain;->callIface(LIface;)V
-
- const-string v0, "Calling functions on interface Iface2"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- invoke-static {v2}, LMain;->callIface2(LIface2;)V
-
- return-void
-.end method
-
-.method public static callIface(LIface;)V
- .locals 2
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "Calling non-conflicting function on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-interface {p0}, LIface;->charge()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Calling conflicting function on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- :try_start
- invoke-interface {p0}, LIface;->sayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Unexpected no error Thrown on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- goto :error_end
- :try_end
- .catch Ljava/lang/AbstractMethodError; {:try_start .. :try_end} :AME_error_start
- .catch Ljava/lang/IncompatibleClassChangeError; {:try_start .. :try_end} :ICCE_error_start
- :AME_error_start
- const-string v0, "Unexpected AME Thrown on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :ICCE_error_start
- const-string v0, "Expected ICCE Thrown on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :error_end
- const-string v0, "Calling non-conflicting function on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-interface {p0}, LIface;->charge()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- return-void
-.end method
-
-.method public static callIface2(LIface2;)V
- .locals 2
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "Calling conflicting function on Iface2"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- :try_start
- invoke-interface {p0}, LIface2;->sayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Unexpected no error Thrown on Iface2"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- goto :error_end
- :try_end
- .catch Ljava/lang/AbstractMethodError; {:try_start .. :try_end} :AME_error_start
- .catch Ljava/lang/IncompatibleClassChangeError; {:try_start .. :try_end} :ICCE_error_start
- :AME_error_start
- const-string v0, "Unexpected AME Thrown on Iface2"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :ICCE_error_start
- const-string v0, "Expected ICCE Thrown on Iface2"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :error_end
-
- return-void
-.end method
-
-.method public static callMain(LMain;)V
- .locals 2
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "Calling non-conflicting function on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-virtual {p0}, LMain;->charge()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Calling conflicting function on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- :try_start
- invoke-virtual {p0}, LMain;->sayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Unexpected no error Thrown on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- goto :error_end
- :try_end
- .catch Ljava/lang/AbstractMethodError; {:try_start .. :try_end} :AME_error_start
- .catch Ljava/lang/IncompatibleClassChangeError; {:try_start .. :try_end} :ICCE_error_start
- :AME_error_start
- const-string v0, "Unexpected AME Thrown on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :ICCE_error_start
- const-string v0, "Expected ICCE Thrown on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :error_end
- const-string v0, "Calling non-conflicting function on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-virtual {p0}, LMain;->charge()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- return-void
-.end method
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface {
+ public default String sayHi() {
+ return "Hi";
+ }
+ public default String charge() {
+ return "CHARGE";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+class Main implements Iface, Iface2 {
+ public static void main(String[] args) {
+ System.out.println("Create Main instance");
+ Main m = new Main();
+ System.out.println("Calling functions on concrete Main");
+ callMain(m);
+ System.out.println("Calling functions on interface Iface");
+ callIface(m);
+ System.out.println("Calling functions on interface Iface2");
+ callIface2(m);
+ }
+ public static void callMain(Main m) {
+ System.out.println("Calling non-conflicting function on Main");
+ System.out.println(m.charge());
+ System.out.println("Calling conflicting function on Main");
+ try {
+ System.out.println(m.sayHi());
+ System.out.println("Unexpected no error Thrown on Main");
+ } catch (AbstractMethodError e) {
+ System.out.println("Unexpected AME Thrown on Main");
+ } catch (IncompatibleClassChangeError e) {
+ System.out.println("Expected ICCE Thrown on Main");
+ }
+ System.out.println("Calling non-conflicting function on Main");
+ System.out.println(m.charge());
+ return;
+ }
+ public static void callIface(Iface m) {
+ System.out.println("Calling non-conflicting function on Iface");
+ System.out.println(m.charge());
+ System.out.println("Calling conflicting function on Iface");
+ try {
+ System.out.println(m.sayHi());
+ System.out.println("Unexpected no error Thrown on Iface");
+ } catch (AbstractMethodError e) {
+ System.out.println("Unexpected AME Thrown on Iface");
+ } catch (IncompatibleClassChangeError e) {
+ System.out.println("Expected ICCE Thrown on Iface");
+ }
+ System.out.println("Calling non-conflicting function on Iface");
+ System.out.println(m.charge());
+ return;
+ }
+ public static void callIface2(Iface2 m) {
+ System.out.println("Calling conflicting function on Iface2");
+ try {
+ System.out.println(m.sayHi());
+ System.out.println("Unexpected no error Thrown on Iface2");
+ } catch (AbstractMethodError e) {
+ System.out.println("Unexpected AME Thrown on Iface2");
+ } catch (IncompatibleClassChangeError e) {
+ System.out.println("Expected ICCE Thrown on Iface2");
+ }
+ return;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface2 {
+ public default String sayHi() {
+ return "hello";
+ }
+}
# make us exit on a failure
set -e
-# TODO: Support running with jack.
-
-if [[ $@ == *"--jvm"* ]]; then
- # Build the Java files if we are running a --jvm test
- mkdir -p src
- mkdir -p classes
- ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src
- # Build with the non-conflicting version
- ${JAVAC} -implicit:none -d classes src/Iface.java build-src/Iface2.java build-src/Iface3.java src/Main.java
- rm classes/Iface2.class
- rm classes/Iface3.class
- # Build with the conflicting version
- ${JAVAC} -implicit:none -cp classes -d classes src/Iface2.java src/Iface3.java
-else
- ./default-build "$@" --experimental default-methods
+if [[ $@ != *"--jvm"* ]]; then
+ # Don't do anything with jvm
+ # Hard-wired use of experimental jack.
+ # TODO: fix this temporary work-around for default-methods, see b/19467889
+ export USE_JACK=true
fi
+
+./default-build "$@" --experimental default-methods
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface Iface {
-# public default String sayHi() {
-# return "Hi";
-# }
-# public default String charge() {
-# return "CHARGE";
-# }
-# }
-
-.class public abstract interface LIface;
-.super Ljava/lang/Object;
-
-.method public sayHi()Ljava/lang/String;
- .locals 1
- const-string v0, "Hi"
- return-object v0
-.end method
-
-.method public charge()Ljava/lang/String;
- .locals 1
- const-string v0, "CHARGE"
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface Iface2 extends Iface {
-# public String sayHi();
-# }
-
-.class public abstract interface LIface2;
-.super Ljava/lang/Object;
-.implements LIface;
-
-.method public abstract sayHi()Ljava/lang/String;
-.end method
-
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface Iface3 {
-# public String charge();
-# }
-
-.class public abstract interface LIface3;
-.super Ljava/lang/Object;
-
-.method public abstract charge()Ljava/lang/String;
-.end method
-
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# class Main implements Iface, Iface2, Iface3 {
-# public static void main(String[] args) {
-# System.out.println("Create Main instance");
-# Main m = new Main();
-# System.out.println("Calling functions on concrete Main");
-# callMain(m);
-# System.out.println("Calling functions on interface Iface");
-# callIface(m);
-# System.out.println("Calling functions on interface Iface2");
-# callIface2(m);
-# }
-#
-# public static void callMain(Main m) {
-# System.out.println("Calling non-abstract function on Main");
-# System.out.println(m.charge());
-# System.out.println("Calling abstract function on Main");
-# try {
-# System.out.println(m.sayHi());
-# System.out.println("Unexpected no error Thrown on Main");
-# } catch (AbstractMethodError e) {
-# System.out.println("Expected AME Thrown on Main");
-# } catch (IncompatibleClassChangeError e) {
-# System.out.println("Unexpected ICCE Thrown on Main");
-# }
-# System.out.println("Calling non-abstract function on Main");
-# System.out.println(m.charge());
-# return;
-# }
-#
-# public static void callIface(Iface m) {
-# System.out.println("Calling non-abstract function on Iface");
-# System.out.println(m.charge());
-# System.out.println("Calling abstract function on Iface");
-# try {
-# System.out.println(m.sayHi());
-# System.out.println("Unexpected no error Thrown on Iface");
-# } catch (AbstractMethodError e) {
-# System.out.println("Expected AME Thrown on Iface");
-# } catch (IncompatibleClassChangeError e) {
-# System.out.println("Unexpected ICCE Thrown on Iface");
-# }
-# System.out.println("Calling non-abstract function on Iface");
-# System.out.println(m.charge());
-# return;
-# }
-#
-# public static void callIface2(Iface2 m) {
-# System.out.println("Calling abstract function on Iface2");
-# try {
-# System.out.println(m.sayHi());
-# System.out.println("Unexpected no error Thrown on Iface2");
-# } catch (AbstractMethodError e) {
-# System.out.println("Expected AME Thrown on Iface2");
-# } catch (IncompatibleClassChangeError e) {
-# System.out.println("Unexpected ICCE Thrown on Iface2");
-# }
-# return;
-# }
-# }
-
-.class public LMain;
-.super Ljava/lang/Object;
-.implements LIface;
-.implements LIface2;
-.implements LIface3;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public static main([Ljava/lang/String;)V
- .locals 3
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
-
- const-string v0, "Create Main instance"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- new-instance v2, LMain;
- invoke-direct {v2}, LMain;-><init>()V
-
- const-string v0, "Calling functions on concrete Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- invoke-static {v2}, LMain;->callMain(LMain;)V
-
- const-string v0, "Calling functions on interface Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- invoke-static {v2}, LMain;->callIface(LIface;)V
-
- const-string v0, "Calling functions on interface Iface2"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- invoke-static {v2}, LMain;->callIface2(LIface2;)V
-
- return-void
-.end method
-
-.method public static callIface(LIface;)V
- .locals 2
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "Calling non-abstract function on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-interface {p0}, LIface;->charge()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Calling abstract function on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- :try_start
- invoke-interface {p0}, LIface;->sayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Unexpected no error Thrown on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- goto :error_end
- :try_end
- .catch Ljava/lang/AbstractMethodError; {:try_start .. :try_end} :AME_error_start
- .catch Ljava/lang/IncompatibleClassChangeError; {:try_start .. :try_end} :ICCE_error_start
- :AME_error_start
- const-string v0, "Expected AME Thrown on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :ICCE_error_start
- const-string v0, "Unexpected ICCE Thrown on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :error_end
- const-string v0, "Calling non-abstract function on Iface"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-interface {p0}, LIface;->charge()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- return-void
-.end method
-
-.method public static callIface2(LIface2;)V
- .locals 2
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "Calling abstract function on Iface2"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- :try_start
- invoke-interface {p0}, LIface2;->sayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Unexpected no error Thrown on Iface2"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- goto :error_end
- :try_end
- .catch Ljava/lang/AbstractMethodError; {:try_start .. :try_end} :AME_error_start
- .catch Ljava/lang/IncompatibleClassChangeError; {:try_start .. :try_end} :ICCE_error_start
- :AME_error_start
- const-string v0, "Expected AME Thrown on Iface2"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :ICCE_error_start
- const-string v0, "Unexpected ICCE Thrown on Iface2"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :error_end
-
- return-void
-.end method
-
-.method public static callMain(LMain;)V
- .locals 2
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "Calling non-abstract function on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-virtual {p0}, LMain;->charge()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Calling abstract function on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- :try_start
- invoke-virtual {p0}, LMain;->sayHi()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "Unexpected no error Thrown on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- goto :error_end
- :try_end
- .catch Ljava/lang/AbstractMethodError; {:try_start .. :try_end} :AME_error_start
- .catch Ljava/lang/IncompatibleClassChangeError; {:try_start .. :try_end} :ICCE_error_start
- :AME_error_start
- const-string v0, "Expected AME Thrown on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :ICCE_error_start
- const-string v0, "Unexpected ICCE Thrown on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- goto :error_end
- :error_end
- const-string v0, "Calling non-abstract function on Main"
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- invoke-virtual {p0}, LMain;->charge()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- return-void
-.end method
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface {
+ public default String sayHi() {
+ return "Hi";
+ }
+ public default String charge() {
+ return "CHARGE";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+class Main implements Iface, Iface2, Iface3 {
+ public static void main(String[] args) {
+ System.out.println("Create Main instance");
+ Main m = new Main();
+ System.out.println("Calling functions on concrete Main");
+ callMain(m);
+ System.out.println("Calling functions on interface Iface");
+ callIface(m);
+ System.out.println("Calling functions on interface Iface2");
+ callIface2(m);
+ }
+ public static void callMain(Main m) {
+ System.out.println("Calling non-abstract function on Main");
+ System.out.println(m.charge());
+ System.out.println("Calling abstract function on Main");
+ try {
+ System.out.println(m.sayHi());
+ System.out.println("Unexpected no error Thrown on Main");
+ } catch (AbstractMethodError e) {
+ System.out.println("Expected AME Thrown on Main");
+ } catch (IncompatibleClassChangeError e) {
+ System.out.println("Unexpected ICCE Thrown on Main");
+ }
+ System.out.println("Calling non-abstract function on Main");
+ System.out.println(m.charge());
+ return;
+ }
+ public static void callIface(Iface m) {
+ System.out.println("Calling non-abstract function on Iface");
+ System.out.println(m.charge());
+ System.out.println("Calling abstract function on Iface");
+ try {
+ System.out.println(m.sayHi());
+ System.out.println("Unexpected no error Thrown on Iface");
+ } catch (AbstractMethodError e) {
+ System.out.println("Expected AME Thrown on Iface");
+ } catch (IncompatibleClassChangeError e) {
+ System.out.println("Unexpected ICCE Thrown on Iface");
+ }
+ System.out.println("Calling non-abstract function on Iface");
+ System.out.println(m.charge());
+ return;
+ }
+ public static void callIface2(Iface2 m) {
+ System.out.println("Calling abstract function on Iface2");
+ try {
+ System.out.println(m.sayHi());
+ System.out.println("Unexpected no error Thrown on Iface2");
+ } catch (AbstractMethodError e) {
+ System.out.println("Expected AME Thrown on Iface2");
+ } catch (IncompatibleClassChangeError e) {
+ System.out.println("Unexpected ICCE Thrown on Iface2");
+ }
+ return;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface {
+ public default String sayHi() {
+ return "Hi";
+ }
+ public default String charge() {
+ return "CHARGE";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface2 extends Iface {
+ public String sayHi();
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface3 {
+ public String charge();
+}
# make us exit on a failure
set -e
-# Should we compile with Java source code. By default we will use Smali.
-USES_JAVA_SOURCE="false"
-if [[ $@ == *"--jvm"* ]]; then
- USES_JAVA_SOURCE="true"
-elif [[ "$USE_JACK" == "true" ]]; then
- if $JACK -D jack.java.source.version=1.8 2>/dev/null; then
- USES_JAVA_SOURCE="true"
- else
- echo "WARNING: Cannot use jack because it does not support JLS 1.8. Falling back to smali" >&2
- fi
+if [[ $@ != *"--jvm"* ]]; then
+ # Don't do anything with jvm
+ # Hard-wired use of experimental jack.
+ # TODO: fix this temporary work-around for default-methods, see b/19467889
+ export USE_JACK=true
fi
-# Generate the smali Main.smali file or fail
-${ANDROID_BUILD_TOP}/art/test/utils/python/generate_smali_main.py ./smali
+# Generate the Main.java file or fail
+${ANDROID_BUILD_TOP}/art/test/utils/python/generate_java_main.py ./src
-if [[ "$USES_JAVA_SOURCE" == "true" ]]; then
- # We are compiling java code, create it.
- mkdir -p src
- ${ANDROID_BUILD_TOP}/art/tools/extract-embedded-java ./smali ./src
- # Ignore the smali directory.
- EXTRA_ARGS="--no-smali"
-fi
-
-./default-build "$@" "$EXTRA_ARGS" --experimental default-methods
+./default-build "$@" --experimental default-methods
Testing for type A
A-virtual A.SayHi()='Hello '
-A-interface iface.SayHi()='Hello '
+A-interface Iface.SayHi()='Hello '
End testing for type A
Testing for type B
B-virtual B.SayHi()='Hello Hello '
-B-interface iface.SayHi()='Hello Hello '
-B-interface iface2.SayHi()='Hello Hello '
+B-interface Iface.SayHi()='Hello Hello '
+B-interface Iface2.SayHi()='Hello Hello '
End testing for type B
Testing for type C
C-virtual C.SayHi()='Hello and welcome '
-C-interface iface.SayHi()='Hello and welcome '
+C-interface Iface.SayHi()='Hello and welcome '
End testing for type C
Testing for type D
D-virtual D.SayHi()='Hello Hello and welcome '
-D-interface iface.SayHi()='Hello Hello and welcome '
-D-interface iface2.SayHi()='Hello Hello and welcome '
+D-interface Iface.SayHi()='Hello Hello and welcome '
+D-interface Iface2.SayHi()='Hello Hello and welcome '
End testing for type D
Testing for type E
E-virtual E.SayHi()='Hello there!'
-E-interface iface.SayHi()='Hello there!'
-E-interface iface3.SayHi()='Hello there!'
+E-interface Iface.SayHi()='Hello there!'
+E-interface Iface3.SayHi()='Hello there!'
End testing for type E
Testing for type F
F-virtual E.SayHi()='Hello there!'
F-virtual F.SayHi()='Hello there!'
-F-interface iface.SayHi()='Hello there!'
-F-interface iface3.SayHi()='Hello there!'
+F-interface Iface.SayHi()='Hello there!'
+F-interface Iface3.SayHi()='Hello there!'
F-virtual F.SaySurprisedHi()='Hello there!!'
End testing for type F
Testing for type G
G-virtual E.SayHi()='Hello there!?'
G-virtual F.SayHi()='Hello there!?'
G-virtual G.SayHi()='Hello there!?'
-G-interface iface.SayHi()='Hello there!?'
-G-interface iface3.SayHi()='Hello there!?'
+G-interface Iface.SayHi()='Hello there!?'
+G-interface Iface3.SayHi()='Hello there!?'
G-virtual F.SaySurprisedHi()='Hello there!!'
G-virtual G.SaySurprisedHi()='Hello there!!'
G-virtual G.SayVerySurprisedHi()='Hello there!!!'
H-virtual H.SayConfusedHi()='Hello ?!'
H-virtual A.SayHi()='Hello ?'
H-virtual H.SayHi()='Hello ?'
-H-interface iface.SayHi()='Hello ?'
+H-interface Iface.SayHi()='Hello ?'
H-virtual H.SaySurprisedHi()='Hello !'
End testing for type H
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public class A implements iface {
-# }
-
-.class public LA;
-.super Ljava/lang/Object;
-.implements Liface;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public class B implements iface2 {
-# }
-
-.class public LB;
-.super Ljava/lang/Object;
-.implements Liface2;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public class C implements iface {
-# public String SayHi() {
-# return iface.super.SayHi() + " and welcome ";
-# }
-# }
-
-.class public LC;
-.super Ljava/lang/Object;
-.implements Liface;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public SayHi()Ljava/lang/String;
- .locals 2
- invoke-super {p0}, Liface;->SayHi()Ljava/lang/String;
- move-result-object v0
- const-string v1, " and welcome "
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public class D implements iface2 {
-# public String SayHi() {
-# return iface2.super.SayHi() + " and welcome ";
-# }
-# }
-
-.class public LD;
-.super Ljava/lang/Object;
-.implements Liface2;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public SayHi()Ljava/lang/String;
- .locals 2
- invoke-super {p0}, Liface2;->SayHi()Ljava/lang/String;
- move-result-object v0
- const-string v1, " and welcome "
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public class E implements iface3 {
-# public String SayHi() {
-# return iface3.super.SayHi() + " there!";
-# }
-# }
-
-.class public LE;
-.super Ljava/lang/Object;
-.implements Liface3;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-.method public SayHi()Ljava/lang/String;
- .locals 2
- invoke-super {p0}, Liface3;->SayHi()Ljava/lang/String;
- move-result-object v0
- const-string v1, " there!"
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public class F extends E {
-# public String SaySurprisedHi() {
-# return super.SayHi() + "!";
-# }
-# }
-
-.class public LF;
-.super LE;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, LE;-><init>()V
- return-void
-.end method
-
-.method public SaySurprisedHi()Ljava/lang/String;
- .registers 2
- invoke-super {p0}, LE;->SayHi()Ljava/lang/String;
- move-result-object v0
- const-string v1, "!"
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public class G extends F {
-# public String SayHi() {
-# return super.SayHi() + "?";
-# }
-# public String SayVerySurprisedHi() {
-# return super.SaySurprisedHi() + "!";
-# }
-# }
-
-.class public LG;
-.super LF;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, LF;-><init>()V
- return-void
-.end method
-
-.method public SayHi()Ljava/lang/String;
- .locals 2
- invoke-super {p0}, LF;->SayHi()Ljava/lang/String;
- move-result-object v0
- const-string v1, "?"
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
-
-.method public SayVerySurprisedHi()Ljava/lang/String;
- .locals 2
- invoke-super {p0}, LF;->SaySurprisedHi()Ljava/lang/String;
- move-result-object v0
- const-string v1, "!"
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public class H extends A {
-# public String SayHi() {
-# return super.SayHi() + "?";
-# }
-# public String SaySurprisedHi() {
-# return super.SayHi() + "!";
-# }
-# public String SayConfusedHi() {
-# return SayHi() + "!";
-# }
-# }
-
-.class public LH;
-.super LA;
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, LA;-><init>()V
- return-void
-.end method
-
-.method public SayHi()Ljava/lang/String;
- .locals 2
- invoke-super {p0}, LA;->SayHi()Ljava/lang/String;
- move-result-object v0
- const-string v1, "?"
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
-
-.method public SaySurprisedHi()Ljava/lang/String;
- .locals 2
- invoke-super {p0}, LA;->SayHi()Ljava/lang/String;
- move-result-object v0
- const-string v1, "!"
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
-
-.method public SayConfusedHi()Ljava/lang/String;
- .locals 2
- invoke-virtual {p0}, LH;->SayHi()Ljava/lang/String;
- move-result-object v0
- const-string v1, "!"
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface iface {
-# public default String SayHi() {
-# return "Hello ";
-# }
-# }
-
-.class public abstract interface Liface;
-.super Ljava/lang/Object;
-
-.method public SayHi()Ljava/lang/String;
- .locals 1
- const-string v0, "Hello "
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface iface2 extends iface {
-# public default String SayHi() {
-# return iface.super.SayHi() + iface.super.SayHi();
-# }
-# }
-
-.class public abstract interface Liface2;
-.super Ljava/lang/Object;
-.implements Liface;
-
-.method public SayHi()Ljava/lang/String;
- .locals 2
- invoke-super {p0}, Liface;->SayHi()Ljava/lang/String;
- move-result-object v0
- invoke-super {p0}, Liface;->SayHi()Ljava/lang/String;
- move-result-object v1
- invoke-virtual {v0, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- return-object v0
-.end method
+++ /dev/null
-# /*
-# * Copyright (C) 2015 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.
-# */
-#
-# public interface iface3 extends iface {
-# }
-
-.class public abstract interface Liface3;
-.super Ljava/lang/Object;
-.implements Liface;
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public class A implements Iface { }
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public class B implements Iface2 { }
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public class C implements Iface {
+ public String SayHi() {
+ return Iface.super.SayHi() + " and welcome ";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public class D implements Iface2 {
+ public String SayHi() {
+ return Iface2.super.SayHi() + " and welcome ";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public class E implements Iface3 {
+ public String SayHi() {
+ return Iface3.super.SayHi() + " there!";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public class F extends E {
+ public String SaySurprisedHi() {
+ return super.SayHi() + "!";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public class G extends F {
+ public String SayHi() {
+ return super.SayHi() + "?";
+ }
+ public String SayVerySurprisedHi() {
+ return super.SaySurprisedHi() + "!";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public class H extends A {
+ public String SayHi() {
+ return super.SayHi() + "?";
+ }
+ public String SaySurprisedHi() {
+ return super.SayHi() + "!";
+ }
+ public String SayConfusedHi() {
+ return SayHi() + "!";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface {
+ public default String SayHi() {
+ return "Hello ";
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface2 extends Iface {
+ public default String SayHi() {
+ return Iface.super.SayHi() + Iface.super.SayHi();
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 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.
+ */
+public interface Iface3 extends Iface { }
<classes>
<class name="A" super="java/lang/Object">
<implements>
- <item>iface</item>
+ <item>Iface</item>
</implements>
<methods> </methods>
</class>
<class name="B" super="java/lang/Object">
<implements>
- <item>iface2</item>
+ <item>Iface2</item>
</implements>
<methods> </methods>
</class>
<class name="C" super="java/lang/Object">
<implements>
- <item>iface</item>
+ <item>Iface</item>
</implements>
<methods> </methods>
</class>
<class name="D" super="java/lang/Object">
<implements>
- <item>iface2</item>
+ <item>Iface2</item>
</implements>
<methods> </methods>
</class>
<class name="E" super="java/lang/Object">
<implements>
- <item>iface3</item>
+ <item>Iface3</item>
</implements>
<methods> </methods>
</class>
</classes>
<interfaces>
- <interface name="iface" super="java/lang/Object">
+ <interface name="Iface" super="java/lang/Object">
<implements> </implements>
<methods>
<item>SayHi</item>
</methods>
</interface>
- <interface name="iface2" super="java/lang/Object">
+ <interface name="Iface2" super="java/lang/Object">
<implements>
- <item>iface</item>
+ <item>Iface</item>
</implements>
<methods> </methods>
</interface>
- <interface name="iface3" super="java/lang/Object">
+ <interface name="Iface3" super="java/lang/Object">
<implements>
- <item>iface</item>
+ <item>Iface</item>
</implements>
<methods> </methods>
</interface>
# limitations under the License.
"""
-Generate Smali Main file from a classes.xml file.
+Generate Java Main file from a classes.xml file.
"""
import os
import functools
import xml.etree.ElementTree as ET
-class MainClass(mixins.DumpMixin, mixins.Named, mixins.SmaliFileMixin):
+class MainClass(mixins.DumpMixin, mixins.Named, mixins.JavaFileMixin):
"""
A mainclass and main method for this test.
"""
MAIN_CLASS_TEMPLATE = """{copyright}
-.class public LMain;
-.super Ljava/lang/Object;
-
-# class Main {{
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {{p0}}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
+class Main {{
{test_groups}
-
{test_funcs}
-
{main_func}
-
-# }}
+}}
"""
MAIN_FUNCTION_TEMPLATE = """
-# public static void main(String[] args) {{
-.method public static main([Ljava/lang/String;)V
- .locals 2
- sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream;
-
+ public static void main(String[] args) {{
{test_group_invoke}
-
- return-void
-.end method
-# }}
+ }}
"""
TEST_GROUP_INVOKE_TEMPLATE = """
-# {test_name}();
- invoke-static {{}}, {test_name}()V
+ {test_name}();
"""
def __init__(self):
funcs = ""
for f in self.global_funcs:
funcs += str(f)
- return self.MAIN_CLASS_TEMPLATE.format(copyright = get_copyright('smali'),
+ return self.MAIN_CLASS_TEMPLATE.format(copyright = get_copyright('java'),
test_groups=test_groups,
main_func=main_func, test_funcs=funcs)
"""
INSTANCE_TEST_TEMPLATE = """
-# public static void {test_name}() {{
-# System.out.println("Testing for type {ty}");
-# String s = "{ty}";
-# {ty} v = new {ty}();
-.method public static {test_name}()V
- .locals 3
- sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v0, "Testing for type {ty}"
- invoke-virtual {{v2,v0}}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
-
- const-string v0, "{ty}"
- new-instance v1, L{ty};
- invoke-direct {{v1}}, L{ty};-><init>()V
+ public static void {test_name}() {{
+ System.out.println("Testing for type {ty}");
+ String s = "{ty}";
+ {ty} v = new {ty}();
{invokes}
- const-string v0, "End testing for type {ty}"
- invoke-virtual {{v2,v0}}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
- return-void
-.end method
-# System.out.println("End testing for type {ty}");
-# }}
+ System.out.println("End testing for type {ty}");
+ }}
"""
TEST_INVOKE_TEMPLATE = """
-# {fname}(s, v);
- invoke-static {{v0, v1}}, {fname}(Ljava/lang/String;L{farg};)V
+ {fname}(s, v);
"""
def __init__(self, main, ty):
def __str__(self):
"""
- Returns the smali code for this function
+ Returns the java code for this function
"""
func_invokes = ""
for f in sorted(self.funcs, key=lambda a: (a.func, a.farg)):
"""
TEST_FUNCTION_TEMPLATE = """
-# public static void {fname}(String s, {farg} v) {{
-# try {{
-# System.out.printf("%s-{invoke_type:<9} {farg:>9}.{callfunc}()='%s'\\n", s, v.{callfunc}());
-# return;
-# }} catch (Error e) {{
-# System.out.printf("%s-{invoke_type} on {farg}: {callfunc}() threw exception!\\n", s);
-# e.printStackTrace(System.out);
-# }}
-# }}
-.method public static {fname}(Ljava/lang/String;L{farg};)V
- .locals 7
- :call_{fname}_try_start
- const/4 v0, 2
- new-array v1,v0, [Ljava/lang/Object;
- const/4 v0, 0
- aput-object p0,v1,v0
-
- sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v3, "%s-{invoke_type:<9} {farg:>9}.{callfunc}()='%s'\\n"
-
- invoke-{invoke_type} {{p1}}, L{farg};->{callfunc}()Ljava/lang/String;
- move-result-object v4
- const/4 v0, 1
- aput-object v4, v1, v0
-
- invoke-virtual {{v2,v3,v1}}, Ljava/io/PrintStream;->printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
- return-void
- :call_{fname}_try_end
- .catch Ljava/lang/Error; {{:call_{fname}_try_start .. :call_{fname}_try_end}} :error_{fname}_start
- :error_{fname}_start
- move-exception v3
- const/4 v0, 1
- new-array v1,v0, [Ljava/lang/Object;
- const/4 v0, 0
- aput-object p0, v1, v0
- sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream;
- const-string v4, "%s-{invoke_type} on {farg}: {callfunc}() threw exception!\\n"
- invoke-virtual {{v2,v4,v1}}, Ljava/io/PrintStream;->printf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;
- invoke-virtual {{v3,v2}}, Ljava/lang/Error;->printStackTrace(Ljava/io/PrintStream;)V
- return-void
-.end method
+ public static void {fname}(String s, {farg} v) {{
+ try {{
+ System.out.printf("%s-{invoke_type:<9} {farg:>9}.{callfunc}()='%s'\\n", s, v.{callfunc}());
+ return;
+ }} catch (Error e) {{
+ System.out.printf("%s-{invoke_type} on {farg}: {callfunc}() threw exception!\\n", s);
+ e.printStackTrace(System.out);
+ }}
+ }}
"""
def __init__(self, func, farg, invoke):
def __str__(self):
"""
- Get the smali code for this test function
+ Get the java code for this test function
"""
return self.TEST_FUNCTION_TEMPLATE.format(fname=self.get_name(),
farg=self.farg,
def make_main_class(dat):
"""
- Creates a Main.smali file that runs all the tests
+ Creates a Main.java file that runs all the tests
"""
m = MainClass()
for c in dat.classes.values():
return TestData(classes, ifaces)
def main(argv):
- smali_dir = Path(argv[1])
- if not smali_dir.exists() or not smali_dir.is_dir():
- print("{} is not a valid smali dir".format(smali_dir), file=sys.stderr)
+ java_dir = Path(argv[1])
+ if not java_dir.exists() or not java_dir.is_dir():
+ print("{} is not a valid java dir".format(java_dir), file=sys.stderr)
sys.exit(1)
- class_data = parse_xml((smali_dir / "classes.xml").open().read())
- make_main_class(class_data).dump(smali_dir)
+ class_data = parse_xml((java_dir / "classes.xml").open().read())
+ make_main_class(class_data).dump(java_dir)
if __name__ == '__main__':
main(sys.argv)