You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2010/02/24 21:45:27 UTC

svn commit: r915973 - in /directory/apacheds/trunk: core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java

Author: seelmann
Date: Wed Feb 24 20:45:27 2010
New Revision: 915973

URL: http://svn.apache.org/viewvc?rev=915973&view=rev
Log:
Fixed detection of method with Java5

Modified:
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
    directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java?rev=915973&r1=915972&r2=915973&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java (original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java Wed Feb 24 20:45:27 2010
@@ -166,11 +166,14 @@
         // Get the caller by inspecting the stackTrace
         StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
 
+        // In Java5 the 0th stacktrace element is: java.lang.Thread.dumpThreads(Native Method)
+        int index = stackTrace[0].getMethodName().equals( "dumpThreads" ) ? 3 : 2;
+
         // Get the enclosing class
-        Class<?> classCaller = Class.forName( stackTrace[2].getClassName() );
+        Class<?> classCaller = Class.forName( stackTrace[index].getClassName() );
 
         // Get the current method
-        String methodCaller = stackTrace[2].getMethodName();
+        String methodCaller = stackTrace[index].getMethodName();
 
         // Check if we have any annotation associated with the method
         Method[] methods = classCaller.getMethods();

Modified: directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java?rev=915973&r1=915972&r2=915973&view=diff
==============================================================================
--- directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java (original)
+++ directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java Wed Feb 24 20:45:27 2010
@@ -204,12 +204,15 @@
     {
         // Get the caller by inspecting the stackTrace
         StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
-        
+
+        // In Java5 the 0th stacktrace element is: java.lang.Thread.dumpThreads(Native Method)
+        int index = stackTrace[0].getMethodName().equals( "dumpThreads" ) ? 4 : 3;
+
         // Get the enclosing class
-        Class<?> classCaller = Class.forName( stackTrace[3].getClassName() );
+        Class<?> classCaller = Class.forName( stackTrace[index].getClassName() );
 
         // Get the current method
-        String methodCaller = stackTrace[3].getMethodName();
+        String methodCaller = stackTrace[index].getMethodName();
 
         // Check if we have any annotation associated with the method
         Method[] methods = classCaller.getMethods();