enabling java permission checking for everybody. seriously this time :) development
authorhlopkmar
Sat, 01 Dec 2012 12:49:51 +0000
branchdevelopment
changeset 1846 7819e76e5b48
parent 1845 7aacc508afc7
child 1847 5db5d57223fb
enabling java permission checking for everybody. seriously this time :)
JavaResolver.st
libjava.rc
stx_libjava.st
--- a/JavaResolver.st	Fri Nov 30 21:18:34 2012 +0000
+++ b/JavaResolver.st	Sat Dec 01 12:49:51 2012 +0000
@@ -126,14 +126,14 @@
                     self breakPoint: #jv.
                 ]
             ].
-    ] ifFalse: [ 
-        result := self checkIfArrayRef: aJavaClassRef andWrap: result. 
-    ].
+    ] ifFalse: [ result := self checkIfArrayRef: aJavaClassRef andWrap: result. ].
     result isNil ifTrue: [ self breakPoint: #mh ].
     result isJavaPrimitiveType ifTrue: [
         ^ self checkIfPrimitiveArrayRef: aJavaClassRef andWrap: result
     ].
-    (doInit and: [ result isJavaClass and: [result isJavaArrayClass not ]]) ifTrue: [ result classInit ].
+    (doInit and: [ result isJavaClass and: [ result isJavaArrayClass not ] ]) ifTrue: [
+        result classInit
+    ].
      "
      If C is an array class and its element type is a reference type, then the symbolic reference
      to the class or interface representing the element type is resolved by invoking the algorithm
@@ -143,23 +143,16 @@
      public but was changed to be non-public after D was compiled.
      
      If steps 1 and 2 succeed but step 3 fails, C is still valid and usable. Nevertheless, resolution
-     fails, and D is prohibited from accessing C." 
-
-    "JV@2011-08-10: HACK FOR SAXON DEMO!!!!!!" 
-    "(self checkPermissionsFrom: aJavaClassRef owner to: result)"
-
-    "JV@2011-12-07: HACK FOR TOMCAT DEMO :-))"
-    OperatingSystem getLoginName = 'm' ifTrue:[
-        (self checkPermissionsFrom: aJavaClassRef owner to: result) ifTrue: [ ^ result ] ifFalse: [ self throwIllegalAccessError ].
-    ] ifFalse:[
-        ^result
-    ].
+     fails, and D is prohibited from accessing C." "JV@2011-08-10: HACK FOR SAXON DEMO!!!!!!" "(self checkPermissionsFrom: aJavaClassRef owner to: result)" "JV@2011-12-07: HACK FOR TOMCAT DEMO :-))"  
+        (self checkPermissionsFrom: aJavaClassRef owner to: result) ifTrue: [
+            ^ result
+        ] ifFalse: [ self throwIllegalAccessError ].
 
     "Created: / 11-04-2011 / 19:07:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Created: / 12-08-2011 / 22:19:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified (comment): / 03-10-2011 / 23:03:01 / m"
-    "Modified: / 06-12-2011 / 16:26:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 22-08-2012 / 13:02:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 01-12-2012 / 13:44:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaResolver methodsFor:'class resolving helpers'!
@@ -337,12 +330,11 @@
 
 resolveFieldIndentifiedByRef: aJavaFieldRef 
     | result  class |
-
     self validateFieldRef: aJavaFieldRef.
     result := self lookupFieldIfAlreadyResolved: aJavaFieldRef.
     result ifNotNil: [ ^ result ].
     class := aJavaFieldRef classRef resolve: false.
-    class ifNil: [ self halt: 'should not happen - tell mh' ].
+    class ifNil: [ self error: 'should not happen - tell mh' ].
     result := class lookupFieldByNameAndType: aJavaFieldRef nameAndType.
     result ifNil: [ self throwNoSuchFieldException ].
     (self 
@@ -381,7 +373,7 @@
      impose the loading constraint that TL1=TL2(§5.3.4)."
 
     "Created: / 11-04-2011 / 21:15:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified: / 13-04-2011 / 11:57:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-12-2012 / 13:45:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 resolveStaticFieldIndentifiedByRef: aJavaFieldRef 
@@ -390,7 +382,7 @@
     result := self lookupFieldIfAlreadyResolved: aJavaFieldRef.
     result ifNotNil: [ ^ result ].
     class := aJavaFieldRef classRef resolve: false.
-    class ifNil: [ self halt: 'should not happen - tell mh' ].
+    class ifNil: [ self error: 'should not happen - tell mh' ].
     result := class lookupStaticFieldByNameAndType: aJavaFieldRef nameAndType.
     result ifNil: [ self throwNoSuchFieldException ].
     (self 
@@ -429,19 +421,19 @@
      impose the loading constraint that TL1=TL2(§5.3.4)."
 
     "Created: / 28-04-2011 / 22:31:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-12-2012 / 13:45:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaResolver methodsFor:'field resolving helpers'!
 
-checkPermissionsForField: aJavaField from: accessingJavaClass to: resolvedJavaClass 
-    OperatingSystem getLoginName = 'm' ifFalse: [ ^ true ].
+checkPermissionsForField: aJavaField from: accessingJavaClass to: resolvedJavaClass     
     ^ self 
         checkPermissionsForMethodOrField: aJavaField
         from: accessingJavaClass
         to: resolvedJavaClass.
 
     "Created: / 11-04-2011 / 21:46:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-    "Modified (format): / 12-04-2012 / 10:14:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-12-2012 / 13:45:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 lookupFieldIfAlreadyResolved: aJavaFieldRef 
@@ -452,33 +444,36 @@
 !
 
 validateFieldRef: aJavaFieldRef 
-    aJavaFieldRef isJavaRef ifFalse:[self halt:'I expected Java Ref'].
-    aJavaFieldRef isJavaFieldRef ifFalse:[self halt:'I expected Java Field Ref'].
+    aJavaFieldRef isJavaRef ifFalse: [ self halt: 'I expected Java Ref' ].
+    aJavaFieldRef isJavaFieldRef ifFalse: [
+        self error: 'I expected Java Field Ref'
+    ].
 
     "Created: / 11-04-2011 / 21:16:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-12-2012 / 13:46:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaResolver methodsFor:'interface method resolving'!
 
 resolveInterfaceMethodIdentifiedByRef: aJavaInterfaceMethodRef 
     | result  class |
-
     self validateInterfaceMethodRef: aJavaInterfaceMethodRef.
     result := self 
-                lookupInterfaceMethodIfAlreadyResolved: aJavaInterfaceMethodRef.
+            lookupInterfaceMethodIfAlreadyResolved: aJavaInterfaceMethodRef.
     result ifNotNil: [ ^ result ].
     class := aJavaInterfaceMethodRef classRef resolve: false.
-    class ifNil: [ self halt: 'should not happen - tell mh' ].
+    class ifNil: [ self error: 'should not happen - tell mh' ].
     class isInterface ifFalse: [ self throwIncompatibleClassChangeError ].
     result := class 
-                lookupMethodByNameAndType: aJavaInterfaceMethodRef nameAndType.
+            lookupMethodByNameAndType: aJavaInterfaceMethodRef nameAndType.
     result ifNil: [ self throwNoSuchMethodError ].
     (self 
         checkPermissionsForMethod: result
         from: aJavaInterfaceMethodRef classRef owner
         to: class) ifFalse: [ self throwIllegalAccessError ].
-^ result.
-     "
+    ^ result.
+
+    "
      To resolve an unresolved symbolic reference from D to an interface method in an
      interface C, the symbolic reference to C given by the interface method reference is
      first resolved (§5.4.3.1). Therefore, any exceptions that can be thrown as a result
@@ -487,17 +482,18 @@
      resolved, exceptions relating to the resolution of the interface method reference
      itself can be thrown.
      When resolving an interface method reference:
-     
-     If C is not an interface, interface method resolution throws an IncompatibleClassChangeError.""Otherwise, if the referenced method does not have the same name and descriptor as
-     a method in C or in one of the superinterfaces of C, or in class Object, interface
-     method resolution throws a NoSuchMethodError.
-     Otherwise, let <E, L1> be the interface in which the referenced interface method is
-     actually declared and let L2 be the defining loader of D. Let T0 be the name of
-     the type returned by the referenced method, and let T1, ..., Tn be the names of the
-     argument types of the referenced method. The Java virtual machine must impose the
-     loading constraints TiL1 = TiL2 for i = 0 to n (§5.3.4)."
 
-    "Modified: / 23-05-2011 / 17:56:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+     If C is not an interface, interface method resolution throws an IncompatibleClassChangeError."
+    "Otherwise, if the referenced method does not have the same name and descriptor as
+a method in C or in one of the superinterfaces of C, or in class Object, interface
+method resolution throws a NoSuchMethodError.
+Otherwise, let <E, L1> be the interface in which the referenced interface method is
+actually declared and let L2 be the defining loader of D. Let T0 be the name of
+the type returned by the referenced method, and let T1, ..., Tn be the names of the
+argument types of the referenced method. The Java virtual machine must impose the
+loading constraints TiL1 = TiL2 for i = 0 to n (§5.3.4)."
+
+    "Modified: / 01-12-2012 / 13:46:09 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaResolver methodsFor:'interface method resolving helpers'!
@@ -509,19 +505,21 @@
 !
 
 validateInterfaceMethodRef: aJavaInterfaceMethodRef 
-        aJavaInterfaceMethodRef isJavaRef 
-        ifFalse: [ self halt: 'I expected JavaRef instance as an argument' ].
-    aJavaInterfaceMethodRef isJavaInterfaceMethodRef 
-                ifFalse: [ self halt: 'I expected JavaMethodRef instance as an argument' ].
+    aJavaInterfaceMethodRef isJavaRef ifFalse: [
+        self error: 'I expected JavaRef instance as an argument'
+    ].
+    aJavaInterfaceMethodRef isJavaInterfaceMethodRef ifFalse: [
+        self error: 'I expected JavaMethodRef instance as an argument'
+    ].
 
     "Created: / 13-04-2011 / 11:53:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-12-2012 / 13:46:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaResolver methodsFor:'method resolving'!
 
 resolveMethodIndentifiedByRef: aJavaMethodRef 
     | result  class |
-
     self validateMethodRef: aJavaMethodRef.
     result := self lookupMethodIfAlreadyResolved: aJavaMethodRef.
     result ifNotNil: [ ^ result ].
@@ -576,15 +574,16 @@
      the type returned by the referenced method, and let T1, ..., Tn be the names of
      the argument types of the referenced method. The Java virtual machine must impose
      the loading constraints TiL1=TiL2 for i = 0 to n (§5.3.4)."
+
     "Created: / 11-04-2011 / 19:45:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 14-04-2011 / 00:01:34 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 10-08-2011 / 22:44:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 01-12-2012 / 13:46:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaResolver methodsFor:'method resolving helpers'!
 
-checkPermissionsForMethod: aJavaMethod from: accessingJavaClass to: resolvedJavaClass 
-    OperatingSystem getLoginName = 'm' ifFalse: [ ^ true ].
+checkPermissionsForMethod: aJavaMethod from: accessingJavaClass to: resolvedJavaClass    
     ^ self 
         checkPermissionsForMethodOrField: aJavaMethod
         from: accessingJavaClass
@@ -593,7 +592,7 @@
     "Created: / 11-04-2011 / 20:20:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 24-05-2011 / 14:06:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 09-02-2012 / 23:15:48 / mh <hlopik@gmail.com>"
-    "Modified (format): / 12-04-2012 / 10:14:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-12-2012 / 13:46:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 lookupMethodIfAlreadyResolved: aJavaMethodRef 
@@ -604,10 +603,15 @@
 !
 
 validateMethodRef: aJavaMethodRef 
-    aJavaMethodRef isJavaRef ifFalse:[self halt: 'I expected JavaRef instance as an argument'].
-    aJavaMethodRef isJavaMethodRef ifFalse: [self halt: 'I expected JavaMethodRef instance as an argument'].
+    aJavaMethodRef isJavaRef ifFalse: [
+        self error: 'I expected JavaRef instance as an argument'
+    ].
+    aJavaMethodRef isJavaMethodRef ifFalse: [
+        self error: 'I expected JavaMethodRef instance as an argument'
+    ].
 
     "Created: / 11-04-2011 / 19:47:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 01-12-2012 / 13:47:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaResolver class methodsFor:'documentation'!
--- a/libjava.rc	Fri Nov 30 21:18:34 2012 +0000
+++ b/libjava.rc	Sat Dec 01 12:49:51 2012 +0000
@@ -3,7 +3,7 @@
 // automagically generated from the projectDefinition: stx_libjava.
 //
 VS_VERSION_INFO VERSIONINFO
-  FILEVERSION     6,2,2222,2222
+  FILEVERSION     6,2,2224,2224
   PRODUCTVERSION  6,2,3,0
 #if (__BORLANDC__)
   FILEFLAGSMASK   VS_FF_DEBUG | VS_FF_PRERELEASE
@@ -20,12 +20,12 @@
     BEGIN
       VALUE "CompanyName", "eXept Software AG & SWING Research Group\0"
       VALUE "FileDescription", "Java support for Smalltalk/X (LIB)\0"
-      VALUE "FileVersion", "6.2.2222.2222\0"
+      VALUE "FileVersion", "6.2.2224.2224\0"
       VALUE "InternalName", "stx:libjava\0"
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\nCopyright Jan Vrany, Jan Kurs and Marcel Hlopko\n          SWING Research Group, Czech Technical University In Prague\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.3.0\0"
-      VALUE "ProductDate", "Fri, 30 Nov 2012 21:17:25 GMT\0"
+      VALUE "ProductDate", "Sat, 01 Dec 2012 12:49:28 GMT\0"
     END
 
   END
--- a/stx_libjava.st	Fri Nov 30 21:18:34 2012 +0000
+++ b/stx_libjava.st	Sat Dec 01 12:49:51 2012 +0000
@@ -155,17 +155,17 @@
      exclude individual packages in the #excludedFromPrerequisites method."
 
     ^ #(
-        #'stx:goodies/sunit'    "TestResource - superclass of JavaLookupTestsResource "
+        #'stx:goodies/sunit'    "TestSuite - referenced by stx_libjava class>>testSuite "
         #'stx:libbasic'    "Error - superclass of JavaInvalidRefError "
         #'stx:libbasic2'    "Socket - superclass of JavaSocket "
         #'stx:libbasic3'    "WrappedMethod - extended "
-        #'stx:libcomp'    "BlockNode - referenced by ProxyMethodTypeCheckNode>>generate: "
+        #'stx:libcomp'    "VariableNode - referenced by ProxyMethodCompiler>>compile:arguments:selector: "
         #'stx:libhtml'    "URL - referenced by JavaEmbeddedFrameView>>setupAppletFrameIn:initializeJava: "
         #'stx:libtool'    "WorkspaceApplication - referenced by GroovyEvaluator>>evaluate:in:receiver:notifying:logged:ifFail: "
         #'stx:libview'    "GraphicsMedium - superclass of JavaPopUpView "
         #'stx:libview2'    "Plug - referenced by JavaSourceCodeCache>>findMethodLine:inMethods: "
         #'stx:libwidg'    "HorizontalScrollBar - referenced by JavaVM class>>_WScrollPanePeer__getHScrollbarHeight: "
-        #'stx:libwidg2'    "MenuPanel - referenced by JavaVM class>>processEvent: "
+        #'stx:libwidg2'    "ComboListView - referenced by JavaVM class>>_WChoicePeer_create: "
     )
 ! !