JavaClass.st
branchdevelopment
changeset 2730 272689c14005
parent 2729 ac412f6ea6d4
child 2732 7d1a1fb5b01a
equal deleted inserted replaced
2729:ac412f6ea6d4 2730:272689c14005
   925         current := current enclosingMethod.
   925         current := current enclosingMethod.
   926     ].
   926     ].
   927     ^ enclosing
   927     ^ enclosing
   928 
   928 
   929     "Created: / 13-09-2013 / 11:22:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   929     "Created: / 13-09-2013 / 11:22:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   930 !
       
   931 
       
   932 topNameSpaceName
       
   933     "Return the nameSpace of my topOwningClass (if private) or my own nameSpace."  
       
   934 
       
   935     "/ All classes loaded by system, ext or primordial class loader should go
       
   936     "/ to namespace JAVA. The rest should go a namespace crated for its class loader.
       
   937     "/ this allows for multiple versions of the class to be visible in the browser          
       
   938 
       
   939     | systemLoader extLoader |
       
   940 
       
   941     classLoader isNil ifTrue:[ ^ #JAVA ].
       
   942     systemLoader := JavaVM systemClassLoader.
       
   943     systemLoader notNil ifTrue:[
       
   944         classLoader == systemLoader ifTrue:[ ^ #JAVA ].
       
   945         extLoader := systemLoader instVarNamed: #parent.
       
   946         classLoader == extLoader ifTrue:[ ^ #JAVA ].
       
   947     ].
       
   948 
       
   949     ^ ('JAVA_' , (classLoader identityHash printStringRadix: 16 padTo: 8)) asSymbol.
       
   950 
       
   951     "Created: / 03-09-2013 / 00:38:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   952 !
   930 !
   953 
   931 
   954 typeOfField:aFieldName
   932 typeOfField:aFieldName
   955 
   933 
   956     fields do:[:aField |
   934     fields do:[:aField |
  2584     "return a nameString as shown in browsers"
  2562     "return a nameString as shown in browsers"
  2585 
  2563 
  2586     ^ self name copyReplaceAll:$/ with:$.
  2564     ^ self name copyReplaceAll:$/ with:$.
  2587 !
  2565 !
  2588 
  2566 
  2589 nameSpacePath
  2567 nameInSmalltalk
  2590     |parts s|
  2568     "Return the name of the class under which it could be found in
  2591 
  2569      system dictionary (Smalltalk)"
  2592     parts := self fullName asCollectionOfSubstringsSeparatedBy:$/.
  2570 
  2593     s := '' writeStream.
  2571     ^ self nameSpaceName , '::' , self lastName.
  2594     s nextPutAll:'JAVA'.
  2572 
  2595     parts from:1 to:(parts size - 1) do:[:aPart |
  2573     "Modified: / 19-10-1998 / 20:07:24 / cg"
  2596 	s nextPutAll:'::'.
  2574     "Modified: / 14-09-2013 / 22:54:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2597 	s nextPutAll:aPart
  2575 !
  2598     ].
  2576 
  2599     ^ s contents
  2577 nameSpaceName
  2600 
  2578     "Return the name of the class under which it could be found in
  2601     "
  2579      system dictionary (Smalltalk)"
  2602      JAVA::java::lang::Object fullName
  2580     
       
  2581     ^ String 
       
  2582         streamContents: [:s | 
       
  2583             | parts |
       
  2584 
       
  2585             s nextPutAll: 'JAVA'.
       
  2586             classLoader notNil ifTrue: [
       
  2587                 | systemLoader  extLoader |
       
  2588 
       
  2589                 systemLoader := JavaVM systemClassLoader.
       
  2590                 systemLoader notNil ifTrue: [
       
  2591                     classLoader ~~ systemLoader ifTrue: [
       
  2592                         extLoader := systemLoader instVarNamed: #parent.
       
  2593                         classLoader ~~ extLoader ifTrue: [
       
  2594                             s
       
  2595                                 nextPut: $_;
       
  2596                                 nextPutAll: (classLoader identityHash printStringRadix: 16 padTo: 8).
       
  2597                         ]
       
  2598                     ] ifFalse: [
       
  2599                         s
       
  2600                             nextPut: $_;
       
  2601                             nextPutAll: (classLoader identityHash printStringRadix: 16 padTo: 8).
       
  2602                     ]
       
  2603                 ] ifFalse: [
       
  2604                     s
       
  2605                         nextPut: $_;
       
  2606                         nextPutAll: (classLoader identityHash printStringRadix: 16 padTo: 8).
       
  2607                 ].
       
  2608             ].
       
  2609             parts := self fullName asCollectionOfSubstringsSeparatedBy: $/.
       
  2610             parts 
       
  2611                 from: 1
       
  2612                 to: (parts size - 1)
       
  2613                 do: [:aPart | 
       
  2614                     s nextPutAll: '::'.
       
  2615                     s nextPutAll: aPart
       
  2616                 ].
       
  2617         ].
       
  2618 
       
  2619     "
       
  2620      JAVA::java::lang::Object nameInSmalltalk
  2603      JAVA::java::lang::Object nameSpacePath
  2621      JAVA::java::lang::Object nameSpacePath
  2604      JAVA::java::lang::Object name
  2622      JAVA::java::lang::Object name"
  2605     "
  2623     "Created: / 14-09-2013 / 22:53:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2606 
       
  2607     "Modified: / 19.10.1998 / 20:07:24 / cg"
       
  2608 !
  2624 !
  2609 
  2625 
  2610 selectMethodsAnnotatedWith:aJavaTypeName 
  2626 selectMethodsAnnotatedWith:aJavaTypeName 
  2611     ^ self methodDictionary values select:
  2627     ^ self methodDictionary values select:
  2612             [:method | 
  2628             [:method | 
  2795     ^ JavaArray javaArrayClassFor:self
  2811     ^ JavaArray javaArrayClassFor:self
  2796 
  2812 
  2797     "Created: / 10-11-1998 / 02:07:32 / cg"
  2813     "Created: / 10-11-1998 / 02:07:32 / cg"
  2798     "Modified: / 08-01-1999 / 14:11:34 / cg"
  2814     "Modified: / 08-01-1999 / 14:11:34 / cg"
  2799     "Modified: / 05-07-2012 / 23:24:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2815     "Modified: / 05-07-2012 / 23:24:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2800 !
       
  2801 
       
  2802 updateClassRefsFrom:oldClass to:newClass
       
  2803     self == oldClass ifTrue:[
       
  2804 	self makeObsolete.
       
  2805 	^ self
       
  2806     ].
       
  2807 
       
  2808     constantPool updateClassRefsFrom:oldClass to:newClass.
       
  2809     interfaces notNil ifTrue:[
       
  2810 	interfaces := interfaces collect:[:anInterface |
       
  2811 					    anInterface == oldClass ifTrue:[
       
  2812 						newClass isNil ifTrue:[
       
  2813 						    nil "/ replace by an unresolvedInterface
       
  2814 						] ifFalse:[
       
  2815 						    newClass
       
  2816 						]
       
  2817 					    ] ifFalse:[
       
  2818 						anInterface
       
  2819 					    ]
       
  2820 					 ]
       
  2821     ]
       
  2822 
       
  2823     "Modified: / 4.2.1998 / 22:08:19 / cg"
       
  2824 ! !
  2816 ! !
  2825 
  2817 
  2826 !JavaClass methodsFor:'support - refactorings'!
  2818 !JavaClass methodsFor:'support - refactorings'!
  2827 
  2819 
  2828 directlyDefinesMethod: aSelector 
  2820 directlyDefinesMethod: aSelector