Here you can find the source of getFieldName(JoinPoint jp)
public static String getFieldName(JoinPoint jp)
//package com.java2s; /*//from ww w .jav a2 s . co m * Copyright (c) Ludger Solbach. All rights reserved. * The use and distribution terms for this software are covered by the * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) * which can be found in the file license.txt at the root of this distribution. * By using this software in any fashion, you are agreeing to be bound by * the terms of this license. * You must not remove this notice, or any other, from this software. */ import org.aspectj.lang.JoinPoint; import org.aspectj.lang.Signature; import org.aspectj.lang.reflect.FieldSignature; import org.aspectj.lang.reflect.MethodSignature; public class Main { public static String getFieldName(JoinPoint jp) { Signature sig = jp.getSignature(); if (sig instanceof MethodSignature) { MethodSignature mSig = (MethodSignature) sig; return getFieldNameFromMethodName(mSig.getName()); } else if (sig instanceof FieldSignature) { FieldSignature fSig = (FieldSignature) sig; return fSig.getField().getName(); } return ""; } public static String getFieldNameFromMethodName(String methodName) { String name = ""; if (methodName.startsWith("get") || methodName.startsWith("set")) { name = firstLower(methodName.substring(3)); } else if (methodName.startsWith("is")) { name = firstLower(methodName.substring(2)); } return name; } public static String firstLower(String name) { return name.substring(0, 1).toLowerCase() + name.substring(1); } }