Added the "RecursiveAnnotation" example, which shows a humerous example of an annotation that references itself recursively, causing a stack overflow.

git-svn-id: https://smali.googlecode.com/svn/trunk@68 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2009-06-03 05:08:58 +00:00
parent cf396faa1a
commit dbfce409d4
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,24 @@
.class public LMain;
.super Ljava/lang/Object;
;expected output (using the dalvik's default stack size)
;@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=@RecursiveAnnotation(value=java.lang.StackOverflowError))))))))))))))))))))))))))))))
.method public static main([Ljava/lang/String;)V
.registers 3
sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
const-class v1, LMain;
const-class v2, LRecursiveAnnotation;
invoke-virtual {v1, v2}, Ljava/lang/Class;->getAnnotation(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;
move-result-object v1
invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V
return-void
.end method
.annotation runtime LRecursiveAnnotation;
.end annotation

View File

@ -0,0 +1,18 @@
.class public abstract interface annotation LRecursiveAnnotation;
.super Ljava/lang/Object;
.implements Ljava/lang/annotation/Annotation;
;this is a recursive annotation that has a default value of itself.
;Trying to print .toString() on an instance of this annotation
;will cause a stack overflow
.method public abstract value()LRecursiveAnnotation;
.end method
.annotation system Ldalvik/annotation/AnnotationDefault;
value = .subannotation LRecursiveAnnotation;
value = .subannotation LRecursiveAnnotation;
.end subannotation
.end subannotation
.end annotation