1# Copyright (C) 2023 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# We cannot implement Main in Java, as this would require to run 16# dexmerger (to merge the Dex file produced from Smali code and the 17# Dex file produced from Java code), which loops indefinitely when 18# processing class 301108855, as this class implements itself. As 19# a workaround, implement Main using Smali. 20 21.class public LMain; 22.super Ljava/lang/Object; 23 24.method public static main([Ljava/lang/String;)V 25 .registers 3 26 .param p0, "args" 27 28 invoke-static {}, LMain;->test()V 29 sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; 30 const-string v1, "Done!" 31 invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 32 return-void 33.end method 34 35.method static test()V 36 .registers 4 37 38 :try_start 39 const-string v2, "301108855" 40 invoke-static {v2}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class; 41 :try_end 42 .catch Ljava/lang/ClassCircularityError; {:try_start .. :try_end} :catch 43 44 move-result-object v0 45 46 :goto_7 47 return-void 48 49 :catch 50 move-exception v1 51 .local v1, "e":Ljava/lang/ClassCircularityError; 52 sget-object v2, Ljava/lang/System;->out:Ljava/io/PrintStream; 53 const-string v3, "Caught ClassCircularityError" 54 invoke-virtual {v2, v3}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V 55 goto :goto_7 56.end method 57