From 261835b7200a1a87604d6203de10e04e156528f7 Mon Sep 17 00:00:00 2001 From: Hargett Date: Wed, 20 Apr 2016 22:38:22 -0400 Subject: [PATCH] Add support for proper Tag naming for methods within a enum --- .../src/main/java/hugo/weaving/internal/Hugo.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hugo-runtime/src/main/java/hugo/weaving/internal/Hugo.java b/hugo-runtime/src/main/java/hugo/weaving/internal/Hugo.java index 1d57125..8fed6b8 100644 --- a/hugo-runtime/src/main/java/hugo/weaving/internal/Hugo.java +++ b/hugo-runtime/src/main/java/hugo/weaving/internal/Hugo.java @@ -116,8 +116,17 @@ private static void exitMethod(JoinPoint joinPoint, Object result, long lengthMi private static String asTag(Class cls) { if (cls.isAnonymousClass()) { - return asTag(cls.getEnclosingClass()); + final Class enclosingClass = cls.getEnclosingClass(); + if (enclosingClass.isEnum()) { + String splits[] = cls.getName().split("\\$"); + return enumAsTag(enclosingClass, Integer.parseInt(splits[splits.length-1])); + } + return asTag(enclosingClass); } return cls.getSimpleName(); } + + private static String enumAsTag(Class enclosingClass, int enumIdx) { + return ((Enum)enclosingClass.getEnumConstants()[enumIdx]).name(); + } }