From 855ca0050a41abde84f116a0b9b6e9bb13a5ccb1 Mon Sep 17 00:00:00 2001 From: chibash Date: Mon, 23 Sep 2019 22:12:42 +0900 Subject: [PATCH] adds CtClass#isKotlin() for PR #276 --- src/main/javassist/CtBehavior.java | 5 +++++ src/main/javassist/CtClass.java | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/javassist/CtBehavior.java b/src/main/javassist/CtBehavior.java index fd3dac96..da7cff04 100644 --- a/src/main/javassist/CtBehavior.java +++ b/src/main/javassist/CtBehavior.java @@ -858,6 +858,11 @@ public abstract class CtBehavior extends CtMember { * generate the original bytecode. * The other insertAfter methods calls this method * with false for this parameter. + * A tip is to pass this.getDeclaringClass().isKotlin() + * to this parameter. + * + * @see CtClass#isKotlin() + * @see #getDeclaringClass() * @since 3.26 */ public void insertAfter(String src, boolean asFinally, boolean redundant) diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java index 09cf4b3e..a215246b 100644 --- a/src/main/javassist/CtClass.java +++ b/src/main/javassist/CtClass.java @@ -332,6 +332,14 @@ public abstract class CtClass { return false; } + /** + * Returns true if this object represents a Kotlin class. + * @since 3.26 + */ + public boolean isKotlin() { + return hasAnnotation("kotlin.Metadata"); + } + /** * If this object represents an array, this method returns the component * type of the array. Otherwise, it returns null. -- 2.39.5