- JavaFinalizationRegistry
changed:
#allObjectsIncludingContextsDo:
#finalizeNow
- JavaVM
comment/format in: #_FileDescriptor_initSystemFD:
changed:
#_java_io_FileInputStream_available:
#anyStream_close:
#validateFile:
#validateFileNo:
--- a/src/JavaFinalizationRegistry.st Sat Jul 28 01:26:25 2012 +0000
+++ b/src/JavaFinalizationRegistry.st Sat Jul 28 01:51:28 2012 +0000
@@ -167,7 +167,16 @@
allObjectsIncludingContextsDo:aBlock
- (ObjectMemory allObjectsDo:aBlock) ifFalse:[ ^ false ].
+ | wasBlocked |
+
+ wasBlocked := OperatingSystem blockInterrupts.
+
+ (ObjectMemory allObjectsDo:aBlock) ifFalse:[
+ wasBlocked ifTrue:[
+ OperatingSystem unblockInterrupts.
+ ].
+ ^false
+ ].
ProcessorScheduler knownProcesses do:[:p |
|con|
@@ -177,6 +186,10 @@
con := con sender.
].
].
+ wasBlocked ifTrue:[
+ OperatingSystem unblockInterrupts.
+ ].
+
^ true
"Created: / 28-07-2012 / 02:14:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -453,7 +466,8 @@
finalizeNow
"Force finalization to run now"
- finalizationSemaphore signal
+ finalizationSemaphore signal.
+ finalizationSemaphore signal.
"Created: / 24-07-2012 / 15:28:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
--- a/src/JavaVM.st Sat Jul 28 01:26:25 2012 +0000
+++ b/src/JavaVM.st Sat Jul 28 01:51:28 2012 +0000
@@ -4132,18 +4132,7 @@
jStream := nativeContext receiver.
- fileNo := self validateFileNo:jStream.
- fileNo == 0 ifTrue:[
- Logger log: 'JAVA: file is already closed'severity: #info facility: 'JVM'.
- ^ self "/ already closed
- ].
- file := self getOpenFileAt:fileNo.
- file isNil ifTrue:[
- self halt:'invalid fileNo in close'.
- self internalError:'invalid fileNo in close'.
- ^ self
- ].
-
+ file := self validateFile:jStream.
file == Stdin ifTrue:[
file := StdinReplacementFileQuerySignal raiseRequest.
file isNil ifTrue:[
@@ -4174,7 +4163,7 @@
"Created: / 04-02-1998 / 15:22:03 / cg"
"Modified: / 14-10-1998 / 15:10:07 / cg"
- "Modified: / 07-12-2011 / 21:20:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 28-07-2012 / 02:45:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
anyStream_readBytes:nativeContext
@@ -4531,29 +4520,20 @@
!
validateFile:javaStream
- |fileNo file descriptor|
+ |fileNo file|
fileNo := self validateFileNo:javaStream.
- fileNo isNil ifTrue:[
-"/ self halt:'invalid fileNo in read'.
-"/ self internalError:'invalid fileNo in read'.
- self throwIOExceptionWithMessage:'invalid fileNo in read'.
- ^ nil
- ].
-
file := self getOpenFileAt:fileNo.
file isNil ifTrue:[
-"/ self halt:'invalid fileNo in read'.
-"/ self internalError:'invalid fileNo in read'.
- self throwIOExceptionWithMessage:'invalid fileNo in read'.
- ^ nil
+ self throwIOExceptionWithMessage:('stream with file descriptor %1 closed or was never open' bindWith: fileNo).
+ ^ nil
].
^ file
- "Created: / 4.1.1998 / 16:50:38 / cg"
- "Modified: / 4.1.1998 / 17:50:00 / cg"
+ "Created: / 04-01-1998 / 16:50:38 / cg"
+ "Modified: / 28-07-2012 / 02:44:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
validateFileDescriptor: jFileDescriptor
@@ -4586,7 +4566,7 @@
!
validateFileNo:javaStream
- |fileNo file descriptor|
+ |fileNo descriptor|
"/ JDK 1.1.3 has fileDescriptor wrapped
"/ JDK 1.0 has it directly as integer
@@ -4598,14 +4578,19 @@
fileNo := descriptor instVarNamed:'fd'.
((fileNo == -1) and:[OperatingSystem isMSWINDOWSlike]) ifTrue:[
fileNo := descriptor instVarNamed:'handle'.
- ]
+ ].
+ fileNo isInteger ifFalse:[
+ self throwIOExceptionWithMessage:('invalid fd value in FileDescriptor (%1 [%2])' bindWith: fileNo with: fileNo class).
+ ^self
+ ].
+ ^fileNo
]
].
fileNo isInteger ifFalse:[
"/ self halt:'invalid fileNo in read'.
"/ self internalError:'invalid fileNo in read'.
- self throwIOExceptionWithMessage:'invalid fileNo in read'.
+ self throwIOExceptionWithMessage:('invalid fd value in stream object (%1 [%2])' bindWith: fileNo with: fileNo class).
^ nil
].
@@ -4614,6 +4599,7 @@
"Created: / 04-01-1998 / 17:49:08 / cg"
"Modified: / 13-01-1998 / 14:07:47 / cg"
"Modified: / 18-08-2011 / 20:03:37 / jv"
+ "Modified: / 28-07-2012 / 02:42:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaVM class methodsFor:'helpers - reflection'!
@@ -5583,26 +5569,23 @@
|file|
file := self validateFile:(nativeContext receiver).
- file isNil ifTrue:[
- self throwIOExceptionWithMessage:'invalid fileNo in available'.
- ^ self
- ].
file == Stdin ifTrue:[
- file := StdinReplacementFileQuerySignal raiseRequest.
- file isNil ifTrue:[
- ^ 1
- ]
+ file := StdinReplacementFileQuerySignal raiseRequest.
+ file isNil ifTrue:[
+ ^ 1
+ ]
].
file isFileStream ifTrue:[
- ^ file size - file position + 1
+ ^ file size - file position + 1
].
file atEnd ifTrue:[
- ^ 0.
+ ^ 0.
].
self halt.
^ 1
- "Modified: / 14.1.1998 / 15:12:52 / cg"
+ "Modified: / 14-01-1998 / 15:12:52 / cg"
+ "Modified: / 28-07-2012 / 02:45:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_java_io_FileInputStream_close0: nativeContext
@@ -10495,24 +10478,24 @@
!
_FileDescriptor_initSystemFD:nativeContext
- |descriptor fileNo idx myStream|
+ |descriptor fileNo myStream|
descriptor := nativeContext argAt:1.
fileNo := nativeContext argAt:2.
fileNo == 0 ifTrue:[
- myStream := Stdin
+ myStream := Stdin
] ifFalse:[
- fileNo == 1 ifTrue:[
- myStream := JavaConsoleStream ? Stdout
- ] ifFalse:[
- fileNo == 2 ifTrue:[
- myStream := JavaConsoleStream ? Stderr
- ] ifFalse:[
- self halt:'invalid fileNo given'.
- self internalError:'invalid fileNo given'.
- ]
- ]
+ fileNo == 1 ifTrue:[
+ myStream := JavaConsoleStream ? Stdout
+ ] ifFalse:[
+ fileNo == 2 ifTrue:[
+ myStream := JavaConsoleStream ? Stderr
+ ] ifFalse:[
+ self halt:'invalid fileNo given'.
+ self internalError:'invalid fileNo given'.
+ ]
+ ]
].
self setOpenFile:myStream at:fileNo.
@@ -10520,7 +10503,8 @@
descriptor instVarNamed:'fd' put:fileNo.
^ descriptor
- "Modified: / 27.1.1998 / 18:15:28 / cg"
+ "Modified: / 27-01-1998 / 18:15:28 / cg"
+ "Modified (format): / 28-07-2012 / 02:46:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
_FileDescriptor_valid:nativeContext