JavaNativeMethodImpl_OpenJDK6.st
changeset 3199 189c572dbe71
parent 3176 243dcc6b3220
child 3203 185bbb8910e8
--- a/JavaNativeMethodImpl_OpenJDK6.st	Sun Aug 03 23:43:40 2014 +0100
+++ b/JavaNativeMethodImpl_OpenJDK6.st	Mon Aug 04 23:08:33 2014 +0100
@@ -9959,45 +9959,25 @@
      * @since JDK1.1
      */"
 
-    | cls  enclosingClsName  enclosingCls |
+    | cls declaringClass |
 
     cls := Reflection classForJavaClassObject: this.
     (cls isJavaPrimitiveType or: [ cls isJavaArrayClass ]) ifTrue: [ ^ nil ].
-    (cls binaryName includes: $$) ifFalse: [ ^ nil ].
-    enclosingClsName := cls binaryName copyTo: (cls binaryName lastIndexOf: $$) - 1.
-    enclosingCls := JavaVM classForName:enclosingClsName definedBy:nil.
-    enclosingCls isNil ifTrue: [ self error: 'Cannot fins declaring class' ].
-    ^ Reflection javaClassObjectForClass: enclosingCls
-
-    "Modified: / 07-02-2014 / 09:44:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    declaringClass := cls declaringClass.
+    declaringClass notNil ifTrue:[
+        ^ Reflection javaClassObjectForClass: declaringClass
+    ].
+    ^ nil
+
+    "Modified: / 04-08-2014 / 22:54:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Class_getDeclaringClass: this
     <javanative: 'java/lang/Class' name: 'getDeclaringClass()Ljava/lang/Class;'>
-    "
-     /**
-     * If the class or interface represented by this {@code Class} object
-     * is a member of another class, returns the {@code Class} object
-     * representing the class in which it was declared.  This method returns
-     * null if this class or interface is not a member of any other class.  If
-     * this {@code Class} object represents an array class, a primitive
-     * type, or void,then this method returns null.
-     *
-     * @return the declaring class for this class
-     * @since JDK1.1
-     */"
-
-    | cls  enclosingClsName  enclosingCls |
-
-    cls := Reflection classForJavaClassObject: this.
-    (cls isJavaPrimitiveType or: [ cls isJavaArrayClass ]) ifTrue: [ ^ nil ].
-    (cls binaryName includes: $$) ifFalse: [ ^ nil ].
-    enclosingClsName := cls binaryName copyTo: (cls binaryName lastIndexOf: $$) - 1.
-    enclosingCls := JavaVM classForName:enclosingClsName definedBy:nil.
-    enclosingCls isNil ifTrue: [ self error: 'Cannot fins declaring class' ].
-    ^ Reflection javaClassObjectForClass: enclosingCls
-
-    "Modified: / 07-11-2013 / 23:39:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+
+    ^ self _java_lang_Class_getDeclaringClass0: this
+
+    "Modified: / 04-08-2014 / 22:39:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 _java_lang_Class_getEnclosingMethod0: this