--- a/src/extensions.st Thu Aug 16 09:44:50 2012 +0000
+++ b/src/extensions.st Thu Aug 16 11:52:58 2012 +0000
@@ -1,6 +1,4 @@
-"{ Package: 'stx:libjava' }"
-
-!
+"{ Package: 'stx:libjava' }"!
!Behavior methodsFor:'queries'!
@@ -15,6 +13,89 @@
"Created: / 22-02-2012 / 21:53:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
+!Boolean class methodsFor:'queries'!
+
+isJavaPrimitiveType
+
+ ^true
+
+ "Created: / 25-02-2011 / 08:22:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Boolean class methodsFor:'queries'!
+
+javaArrayClass
+ ^ BooleanArray
+
+ "Created: / 25-02-2011 / 08:27:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Boolean class methodsFor:'autoboxing support'!
+
+javaBox: anObject
+ | wrapper |
+
+ wrapper := (JavaVM classForName: 'java.lang.Boolean') new.
+ wrapper perform: #'<init>(Z)V' with: anObject.
+ ^ wrapper
+
+ "Created: / 16-08-2011 / 09:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Boolean class methodsFor:'accessing'!
+
+javaName
+
+ ^'boolean'.
+
+ "Modified: / 25-02-2011 / 18:58:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Boolean class methodsFor:'autoboxing support'!
+
+javaUnbox: object onError: errorBlock
+
+ | value |
+
+ (object class name = 'java/lang/Boolean') ifFalse:[
+ errorBlock value.
+ ].
+ value := object instVarNamed: #value.
+ (value ~~ 0 and:[value ~~ 1]) ifTrue:[
+ errorBlock value.
+ ].
+ ^value
+
+ "Created: / 22-11-2011 / 11:52:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Boolean class methodsFor:'autoboxing support'!
+
+javaUnwrap: zeroOrOne
+
+ ^zeroOrOne == 1
+
+ "Created: / 10-12-2011 / 20:00:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Boolean class methodsFor:'autoboxing support'!
+
+javaWrap: boolean
+
+ ^boolean ifTrue:[1] ifFalse:[0].
+
+ "Created: / 18-03-2012 / 22:03:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Boolean class methodsFor:'accessing'!
+
+javaWrapperClass
+ ^(Java classForName: 'java.lang.Boolean')
+
+ "Created: / 24-02-2012 / 19:43:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!BooleanArray methodsFor:'queries'!
isInterface
@@ -23,6 +104,176 @@
"Created: / 31-05-2011 / 16:07:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
+!BooleanArray class methodsFor:'testing'!
+
+isInterface
+
+ ^false
+! !
+
+!BooleanArray class methodsFor:'queries'!
+
+isJavaArrayClass
+
+ ^true
+
+ "Created: / 20-12-2010 / 22:47:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BooleanArray class methodsFor:'queries'!
+
+isJavaReferenceType
+
+ "Java arrays are reference types"
+ ^true
+
+ "Created: / 20-12-2010 / 22:30:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BooleanArray class methodsFor:'accessing-java'!
+
+javaArrayClass
+ ^ JavaArray javaArrayClassFor: self
+
+ "Created: / 06-12-2011 / 17:29:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!BooleanArray class methodsFor:'accessing-java'!
+
+javaComponentClass
+
+ ^Boolean
+
+ "Created: / 20-12-2010 / 22:13:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!BooleanArray class methodsFor:'accessing'!
+
+javaName
+
+ ^'[Z'.
+
+ "Modified: / 31-08-2011 / 23:57:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ByteArray class methodsFor:'testing'!
+
+isInterface
+
+ ^false
+! !
+
+!ByteArray class methodsFor:'queries'!
+
+isJavaArrayClass
+
+ ^true
+
+ "Created: / 05-02-2011 / 22:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ByteArray class methodsFor:'queries'!
+
+isJavaReferenceType
+
+ "Java arrays are reference types"
+ ^true
+
+ "Created: / 20-12-2010 / 22:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ByteArray class methodsFor:'accessing-java'!
+
+javaArrayClass
+
+ ^JavaArray javaArrayClassFor: self
+
+ "Created: / 11-06-2011 / 23:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ByteArray class methodsFor:'accessing-java'!
+
+javaComponentClass
+
+ ^JavaByte
+
+ "Created: / 20-12-2010 / 22:05:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ByteArray class methodsFor:'accessing'!
+
+javaName
+
+ ^'[B'.
+
+ "Modified: / 25-02-2011 / 19:02:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Character class methodsFor:'queries'!
+
+isJavaPrimitiveType
+
+ ^true
+
+ "Created: / 20-12-2010 / 22:18:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Character class methodsFor:'accessing'!
+
+javaArrayClass
+ ^ String
+
+ "Created: / 11-02-2011 / 10:44:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Character class methodsFor:'autoboxing support'!
+
+javaBox: anObject
+ | wrapper |
+
+ wrapper := (JavaVM classForName: 'java.lang.Character') new.
+ wrapper perform: #'<init>(C)V' with: anObject codePoint.
+ ^ wrapper
+
+ "Created: / 16-08-2011 / 09:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Character class methodsFor:'accessing'!
+
+javaName
+
+ ^'char'.
+
+ "Modified: / 25-02-2011 / 18:58:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Character class methodsFor:'autoboxing support'!
+
+javaUnbox: object onError: errorBlock
+
+ | value |
+
+ (object class name = 'java/lang/Character') ifFalse:[
+ errorBlock value.
+ ].
+ value := object instVarNamed: #value.
+ (value between: 0 and: 255) ifFalse:[
+ errorBlock value.
+ ].
+ ^value
+
+ "Created: / 22-11-2011 / 11:52:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Character class methodsFor:'accessing'!
+
+javaWrapperClass
+ ^(Java classForName: 'java.lang.Character')
+
+ "Created: / 24-02-2012 / 19:42:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!CharacterArray methodsFor:'java conversions'!
asDottedJavaClassName
@@ -47,6 +298,7 @@
"Created: / 21-10-2011 / 12:31:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Created: / 30-10-2011 / 17:41:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!CharacterArray methodsFor:'java conversions'!
asInternalJavaClassName
@@ -58,6 +310,7 @@
"Created: / 21-10-2011 / 12:31:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 30-10-2011 / 17:40:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!CharacterArray methodsFor:'java conversions'!
asJavaComponentClassName
@@ -71,6 +324,7 @@
].
^ componentClassName.
! !
+
!CharacterArray methodsFor:'java conversions'!
asJavaishClassName
@@ -82,6 +336,7 @@
"Created: / 21-10-2011 / 12:33:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 30-10-2011 / 17:41:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!CharacterArray methodsFor:'java conversions'!
asNiceJavaClassName
@@ -92,6 +347,7 @@
niceName := niceName asString copyReplaceAll: $/ with: $..
^ niceName.
! !
+
!CharacterArray methodsFor:'java conversions'!
asSTXInternalJavaClassName
@@ -106,6 +362,7 @@
].
^internalName.
! !
+
!CharacterArray methodsFor:'java conversions'!
asSlashedJavaClassName
@@ -123,774 +380,19 @@
"Created: / 21-10-2011 / 12:31:51 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Created: / 30-10-2011 / 17:40:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!CharacterArray methodsFor:'java queries'!
isJavaArrayDescriptor
^ self startsWith:$[.
! !
+
!CharacterArray methodsFor:'java queries'!
isJavaPrimitiveTypeDescriptor
^ (self size = 1 and: [ JavaDescriptor baseTypes includesKey: self first ]).
! !
-!Class methodsFor:'accessing - java'!
-
-javaMirror
- ^self javaMirrorClass forClass: self.
-
- "Created: / 31-07-2012 / 17:39:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Class methodsFor:'accessing - java'!
-
-javaMirrorClass
- ^self isJavaPrimitiveType ifTrue:[
- JavaMirror mirrorClassForJavaPrimitive
- ] ifFalse:[
- JavaMirror mirrorClassForAlienClass
- ]
-
- "Created: / 31-07-2012 / 17:39:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Delay methodsFor:'delaying'!
-
-waitWithState:state
- "suspend the current process until either the relative time delta
- has passed (if millisecondDelta is non-nil), or the absolute millisecondTime
- has been reached (if resumptionTime non-nil)."
-
- | wasBlocked currentDelta dueTime now then |
- isInterrupted := false.
- millisecondDelta notNil ifTrue: [
- now := OperatingSystem getMillisecondTime.
- currentDelta := millisecondDelta rounded.
- currentDelta > 16r0fffffff ifTrue: [
- "NOTE: the microsecondTime is increasing monotonically,
- while millisecondTime is wrapping at 16r1fffffff.
- So use the microsecondTime to check when we are finished"
- dueTime := OperatingSystem getMicrosecondTime + (currentDelta * 1000).
- currentDelta := 16r0fffffff.
- ].
- then := OperatingSystem millisecondTimeAdd: now and: currentDelta.
- ] ifFalse: [ then := resumptionTime. ].
- wasBlocked := OperatingSystem blockInterrupts.
- [
- [
- Processor signal: delaySemaphore atMilliseconds: then.
- Processor activeProcess state: state.
- delaySemaphore wait.
- ] doWhile: [
- (dueTime notNil
- and: [
- isInterrupted not
- and: [ (currentDelta := dueTime - OperatingSystem getMicrosecondTime) > 0 ]
- ])
- ifTrue: [
- currentDelta := (currentDelta // 1000) min: 16r0fffffff.
- now := OperatingSystem getMillisecondTime.
- then := OperatingSystem millisecondTimeAdd: now and: currentDelta.
- true.
- ]
- ifFalse: [ false ]
- ].
- ] ensure: [ wasBlocked ifFalse: [ OperatingSystem unblockInterrupts ]. ]
-
- "
- Transcript showCR:'1'.
- (Delay forSeconds:10) wait.
- Transcript showCR:'2'."
-
- "Modified: / 26-02-1997 / 15:21:35 / cg"
- "Modified: / 18-04-1997 / 11:56:46 / stefan"
- "Created: / 30-11-2011 / 13:38:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!ExecutableFunction methodsFor:'queries'!
-
-isJavaConstructor
- ^ false
-
- "Created: / 31-07-2012 / 18:42:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Object methodsFor:'testing'!
-
-isGroovyClass
- ^false
-
- "Created: / 18-02-2012 / 20:29:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Object methodsFor:'testing'!
-
-isJavaArray
-
- ^self class isJavaArrayClass
-
- "Created: / 19-12-2010 / 17:05:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Object methodsFor:'testing'!
-
-isJavaNameAndType
- "return true, if given object represents name and type struct in java constant pool"
-
- ^ false.
-
- "Created: / 10-05-2011 / 12:21:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!Object methodsFor:'testing'!
-
-isJavaPackage
- "return true, if the receiver is a java package.
- False is returned here - the method is only redefined in JavaPackage."
-
- ^ false
-
- "Created: / 09-08-2011 / 09:35:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Object methodsFor:'testing'!
-
-isJavaRef
-"return true, if given object represents reference in java constant pool"
-^ false.
-
- "Created: / 08-04-2011 / 16:12:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!Object methodsFor:'testing'!
-
-isJavaWrapperClass
- "return true, if this is a java wrapper class, i.e, java.lang.Integer, java.lang.Boolean etc."
-
- ^ false
-
- "Created: / 01-01-2012 / 17:25:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Object methodsFor:'autoboxing support'!
-
-javaBox: anObject
-
- ^anObject
-
- "Created: / 15-08-2011 / 10:52:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Object methodsFor:'autoboxing support'!
-
-javaUnwrap: anObject
- "Unwraps the objects. Possibly call on the wrapped class"
-
- ^anObject
-
- "Created: / 10-12-2011 / 19:51:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Object methodsFor:'autoboxing support'!
-
-javaUnwrapFrom: javaType
- ^ self.
-
- "Created: / 10-12-2011 / 19:51:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Created: / 30-12-2011 / 15:22:06 / kursjan <kursjan@fit.cvut.cz>"
-! !
-!Object methodsFor:'autoboxing support'!
-
-javaWrap: anObject
- "Wraps the receiver into corresponding Java object"
-
- ^anObject
-
- "Created: / 26-12-2011 / 00:57:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Process methodsFor:'Java protocol'!
-
-clearInterrupted
- JavaVM threadInterrupts at: self put: false.
-
- "Created: / 30-11-2011 / 10:44:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!Process methodsFor:'Java protocol'!
-
-isInterrupted
-
- ^ JavaVM threadInterrupts at: self
- ifAbsent: [ JavaVM threadInterrupts at: self put: false. ]
-
- "Created: / 30-11-2011 / 12:12:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!Process methodsFor:'queries'!
-
-isSleeping
- "return true, iff the receiver is sleeping on Delay"
-
- ^ (state == #sleep)
-
- "Created: / 30-11-2011 / 13:35:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!Process methodsFor:'queries'!
-
-isWaiting
- "return true, iff the receiver is waiting on semaphore or something"
-
- ^ (state == #wait)
-
- "Created: / 20-11-2011 / 20:55:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!Process methodsFor:'Java protocol'!
-
-javaInterrupt
- self isWaiting ifTrue: [
- self
- interruptWith: [
- JavaVM
- throwInterruptedException: 'thread has been interrupted during wait'.
- self terminate
- ]
- ] ifFalse: [
- self isSleeping ifTrue: [
-
- self
- interruptWith: [
- JavaVM
- throwInterruptedException: 'thread has been interrupted during sleep'.
- self terminate
- ]
- ] ifFalse: [ self setInterrupted. ]
- ]
-
- "Created: / 30-11-2011 / 13:35:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!Process methodsFor:'Java protocol'!
-
-setInterrupted
-
- JavaVM threadInterrupts at: self put: true.
-
- "Created: / 30-11-2011 / 10:44:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!ProgrammingLanguage methodsFor:'testing'!
-
-isGroovy
- "true iff this is a Groovy language"
-
- ^ false
-
- "Created: / 13-04-2012 / 17:47:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!ProgrammingLanguage methodsFor:'testing'!
-
-isJavaLike
- "true if receiver is kind of Java language (based on Java)"
-
- ^ false
-
- "Created: / 13-04-2012 / 17:48:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Set methodsFor:'javaProtocol'!
-
-java__contains:anObject
- ^ self contains: [:el | anObject = el ]
-! !
-!SmallInteger methodsFor:'autoboxing'!
-
-javaUnwrapFrom: javaType
- javaType = #boolean ifTrue: [
- ^ self = 1
- ].
- ^ self
-
- "Created: / 30-12-2011 / 15:22:52 / kursjan <kursjan@fit.cvut.cz>"
-! !
-!String methodsFor:'converting'!
-
-asArrayOfSubstringsSeparatedBy:aSeparator
- "Modified version of asArrayOfSubstrings"
-
- |substrings start end|
-
- substrings := OrderedCollection new.
- start := 1.
- [start <= self size] whileTrue:[
- (self at:start) = aSeparator ifFalse:[
- end := start + 1.
- [
- end <= self size and:[(self at:end) ~= aSeparator]
- ] whileTrue:[end := end + 1].
- substrings add:(self copyFrom:start to:end - 1).
- start := end - 1
- ].
- start := start + 1
- ].
- ^ substrings asArray
-
- "Created: / 07-02-2011 / 11:18:03 / Marcel Hlopko <hlopik@gmail.com>"
- "Modified: / 08-02-2011 / 01:08:15 / Marcel Hlopko <hlopik@gmail.com>"
-! !
-!UserPreferences methodsFor:'accessing-java'!
-
-javaClassPath
- "Return the Java user-defined class path encoded as literal array"
-
- ^ self at:#javaClassPath ifAbsent:[#()].
-
- "
- UserPreferences current javaClassPath
- UserPreferences current javaClassPath: #openJDK7
-
- Java classPath
- "
-
- "Created: / 27-07-2012 / 12:52:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!UserPreferences methodsFor:'accessing-java'!
-
-javaClassPath: literalArrayEncoding
- "Sets the Java user-defined class path as literalArrayEncoding of a collection
- of JavaPathElements"
-
- self at:#javaClassPath put: literalArrayEncoding.
- (Java notNil and:[thisContext sender receiver == Java]) ifFalse:[
- | classPath |
- classPath := literalArrayEncoding decodeAsLiteralArray.
- Java classPath: classPath.
- ].
-
-
- "
- UserPreferences current javaClassPath
- UserPreferences current javaClassPath: #openJDK7
-
- Java classPath
- "
-
- "Created: / 27-07-2012 / 12:50:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!UserPreferences methodsFor:'accessing-java'!
-
-javaClassPathDecoded
- "Return the Java user-defined class path (a collection of JavaPathElement)"
-
- ^ self javaClassPath decodeAsLiteralArray
-
- "
- UserPreferences current javaClassPathDecoded
- UserPreferences current javaClassPath
-
- Java classPath
- "
-
- "Created: / 02-08-2012 / 09:43:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!UserPreferences methodsFor:'accessing-java'!
-
-javaRelease
- "Return the Java release according to the preferences
- or nil, if not set"
-
- | rel sel |
- sel := self javaReleaseSelector.
- sel notNil ifTrue:[
- rel := JavaRelease perform: sel asSymbol ifNotUnderstood:[nil]
- ].
- ^rel
-
- "Created: / 27-07-2012 / 10:12:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!UserPreferences methodsFor:'accessing-java'!
-
-javaReleaseSelector
- ^ self at:#javaReleaseSelector ifAbsent:[nil].
-
- "
- UserPreferences current javaReleaseSelector
- UserPreferences current javaReleaseSelector: #openJDK6
- UserPreferences current javaReleaseSelector: nil
-
- Java release
- "
-
- "Created: / 27-07-2012 / 10:02:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!UserPreferences methodsFor:'accessing-java'!
-
-javaReleaseSelector: name
- "Sets the Java release to use. selector must be one of
- releases defined in JavaRelease, protocol 'instance creation'"
-
- self at:#javaReleaseSelector put: name.
- Java notNil ifTrue:[
- Java reinitializeRelease
- ].
-
-
- "
- UserPreferences current javaReleaseSelector
- UserPreferences current javaReleaseSelector: #openJDK7
- UserPreferences current javaReleaseSelector: nil
-
- Java release
- Java release:nil
-
- Java reinitializeRelease
- "
-
- "Created: / 27-07-2012 / 10:02:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!UserPreferences methodsFor:'accessing-java'!
-
-javaSourcePath
- "Return the Java user-defined source path encoded as literal array"
-
- ^ self at:#javaSourcePath ifAbsent:[#()].
-
- "
- UserPreferences current javaSourcePath
- UserPreferences current javaSourcePath: #openJDK7
-
- Java sourcePath
- "
-
- "Created: / 27-07-2012 / 12:54:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!UserPreferences methodsFor:'accessing-java'!
-
-javaSourcePath: literalArrayEncoding
- "Sets the Java user-defined source path as literalArrayEncoding of a collection
- of JavaPathElements"
-
- self at:#javaSourcePath put: literalArrayEncoding.
- (Java notNil and:[thisContext sender receiver == Java]) ifFalse:[
- | classPath |
- classPath := literalArrayEncoding decodeAsLiteralArray.
- Java sourceDirectories: classPath.
- ].
-
-
- "
- UserPreferences current javaClassPath
- UserPreferences current javaClassPath: #openJDK7
-
- Java sourceDirectories
- "
-
- "Created: / 27-07-2012 / 12:54:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!UserPreferences methodsFor:'accessing-java'!
-
-javaSourcePathDecoded
- "Return the Java user-defined source path (a collection of JavaPathElement)"
-
- ^ self javaSourcePath decodeAsLiteralArray
-
- "
- UserPreferences current javaSourcePathDecoded
- UserPreferences current javaSourcePath
-
- Java sourceDirectories
- "
-
- "Created: / 02-08-2012 / 09:44:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!UserPreferences methodsFor:'accessing-java-devel'!
-
-javaTestsDirectory
- ^ self at: #javaTestsDirectory
- ifAbsent:
- [ | nm |
-
- nm := OperatingSystem getLoginName.
- "Default path for Jan"
- (nm = 'jv' and:[OperatingSystem isUNIXlike])
- ifTrue:
- [ '/home/jv/Projects/libjava/sources/libjava/branches/jk_new_structure/tests' ]
- ifFalse:
- [ "Default path for Jan (the other one :-)"
- nm = 'jk'
- ifTrue: [ 'path for Jan' ]
- ifFalse:
- [ "Default path for Marcel"
- nm = 'm'
- ifTrue: [ '/home/m/Projects/libjava/branches/jk_new_structure/tests' ]
- ifFalse:
- [ | "Look into package dir" p |
-
- (p := (Smalltalk getPackageDirectoryForPackage: 'stx:libjava') asFilename
- / 'tests') exists
- ifTrue: [ p pathName ]
- ifFalse:
- [ | "Try the environment variable (used by Hudson)" p |
-
- (p := OperatingSystem getEnvironment: 'LIBJAVA_TESTS') notNil
- ifTrue: [ p ]
- ifFalse:
- [ "No default, trigger an error"
- self error: 'No tests path specified' ] ] ] ] ] ]
-
- "
- UserPreferences current javaTestsDirectory"
-
- "Created: / 07-05-2011 / 17:43:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 07-05-2011 / 20:21:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 12-05-2011 / 15:54:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!UserPreferences methodsFor:'accessing-java-devel'!
-
-javaTestsDirectory: aStringOrFilename
-
- self at:#javaTestsDirectory put: aStringOrFilename asString.
-
- "Created: / 07-05-2011 / 17:45:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!WrappedMethod methodsFor:'accessing'!
-
-descriptor
- "Returns descriptor object (for wrapped Java methods)"
-
- | orig |
- orig := self originalMethod.
- ^(orig respondsTo: #descriptor) ifTrue:[
- orig descriptor
- ] ifFalse:[
- self doesNotUnderstand: (Message selector: #descriptor)
- ]
-
- "Created: / 16-12-2011 / 20:03:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!WrappedMethod methodsFor:'queries'!
-
-isAbstract
-
- ^self originalMethod isAbstract.
-
- "Created: / 04-12-2011 / 11:24:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!ZipArchive methodsFor:'reading - java support'!
-
-nextBytes: bytesToRead of: zmember startingAt: pos into: b startingAt: off
-
- file position0Based: zmember fileStart + startOfArchive + pos.
- ^ file nextBytes: bytesToRead into: b startingAt: off.
-
- "Created: / 01-05-2011 / 16:21:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Boolean class methodsFor:'queries'!
-
-isJavaPrimitiveType
-
- ^true
-
- "Created: / 25-02-2011 / 08:22:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Boolean class methodsFor:'queries'!
-
-javaArrayClass
- ^ BooleanArray
-
- "Created: / 25-02-2011 / 08:27:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Boolean class methodsFor:'autoboxing support'!
-
-javaBox: anObject
- | wrapper |
-
- wrapper := (JavaVM classForName: 'java.lang.Boolean') new.
- wrapper perform: #'<init>(Z)V' with: anObject.
- ^ wrapper
-
- "Created: / 16-08-2011 / 09:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Boolean class methodsFor:'accessing'!
-
-javaName
-
- ^'boolean'.
-
- "Modified: / 25-02-2011 / 18:58:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Boolean class methodsFor:'autoboxing support'!
-
-javaUnbox: object onError: errorBlock
-
- | value |
-
- (object class name = 'java/lang/Boolean') ifFalse:[
- errorBlock value.
- ].
- value := object instVarNamed: #value.
- (value ~~ 0 and:[value ~~ 1]) ifTrue:[
- errorBlock value.
- ].
- ^value
-
- "Created: / 22-11-2011 / 11:52:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Boolean class methodsFor:'autoboxing support'!
-
-javaUnwrap: zeroOrOne
-
- ^zeroOrOne == 1
-
- "Created: / 10-12-2011 / 20:00:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Boolean class methodsFor:'autoboxing support'!
-
-javaWrap: boolean
-
- ^boolean ifTrue:[1] ifFalse:[0].
-
- "Created: / 18-03-2012 / 22:03:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Boolean class methodsFor:'accessing'!
-
-javaWrapperClass
- ^(Java classForName: 'java.lang.Boolean')
-
- "Created: / 24-02-2012 / 19:43:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!BooleanArray class methodsFor:'testing'!
-
-isInterface
-
- ^false
-! !
-!BooleanArray class methodsFor:'queries'!
-
-isJavaArrayClass
-
- ^true
-
- "Created: / 20-12-2010 / 22:47:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!BooleanArray class methodsFor:'queries'!
-
-isJavaReferenceType
-
- "Java arrays are reference types"
- ^true
-
- "Created: / 20-12-2010 / 22:30:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!BooleanArray class methodsFor:'accessing-java'!
-
-javaArrayClass
- ^ JavaArray javaArrayClassFor: self
-
- "Created: / 06-12-2011 / 17:29:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-! !
-!BooleanArray class methodsFor:'accessing-java'!
-
-javaComponentClass
-
- ^Boolean
-
- "Created: / 20-12-2010 / 22:13:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!BooleanArray class methodsFor:'accessing'!
-
-javaName
-
- ^'[Z'.
-
- "Modified: / 31-08-2011 / 23:57:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!ByteArray class methodsFor:'testing'!
-
-isInterface
-
- ^false
-! !
-!ByteArray class methodsFor:'queries'!
-
-isJavaArrayClass
-
- ^true
-
- "Created: / 05-02-2011 / 22:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!ByteArray class methodsFor:'queries'!
-
-isJavaReferenceType
-
- "Java arrays are reference types"
- ^true
-
- "Created: / 20-12-2010 / 22:30:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!ByteArray class methodsFor:'accessing-java'!
-
-javaArrayClass
-
- ^JavaArray javaArrayClassFor: self
-
- "Created: / 11-06-2011 / 23:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!ByteArray class methodsFor:'accessing-java'!
-
-javaComponentClass
-
- ^JavaByte
-
- "Created: / 20-12-2010 / 22:05:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!ByteArray class methodsFor:'accessing'!
-
-javaName
-
- ^'[B'.
-
- "Modified: / 25-02-2011 / 19:02:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Character class methodsFor:'queries'!
-
-isJavaPrimitiveType
-
- ^true
-
- "Created: / 20-12-2010 / 22:18:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Character class methodsFor:'accessing'!
-
-javaArrayClass
- ^ String
-
- "Created: / 11-02-2011 / 10:44:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Character class methodsFor:'autoboxing support'!
-
-javaBox: anObject
- | wrapper |
-
- wrapper := (JavaVM classForName: 'java.lang.Character') new.
- wrapper perform: #'<init>(C)V' with: anObject codePoint.
- ^ wrapper
-
- "Created: / 16-08-2011 / 09:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Character class methodsFor:'accessing'!
-
-javaName
-
- ^'char'.
-
- "Modified: / 25-02-2011 / 18:58:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Character class methodsFor:'autoboxing support'!
-
-javaUnbox: object onError: errorBlock
-
- | value |
-
- (object class name = 'java/lang/Character') ifFalse:[
- errorBlock value.
- ].
- value := object instVarNamed: #value.
- (value between: 0 and: 255) ifFalse:[
- errorBlock value.
- ].
- ^value
-
- "Created: / 22-11-2011 / 11:52:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
-!Character class methodsFor:'accessing'!
-
-javaWrapperClass
- ^(Java classForName: 'java.lang.Character')
-
- "Created: / 24-02-2012 / 19:42:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-! !
+
!CharacterArray class methodsFor:'encoding & decoding'!
decodeFromJavaUTF8: bytes
@@ -984,6 +486,7 @@
"Modified: / 13-03-2011 / 15:52:36 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
"Modified: / 09-12-2011 / 19:49:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!CharacterArray class methodsFor:'instance creation'!
fromJavaUTF8Bytes:aByteCollection
@@ -1011,6 +514,7 @@
"Created: / 23-12-2010 / 09:01:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!CharacterArray class methodsFor:'queries'!
isJavaArrayClass
@@ -1019,6 +523,7 @@
"Created: / 05-02-2011 / 22:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!CharacterArray class methodsFor:'accessing-java'!
javaArrayClass
@@ -1028,6 +533,7 @@
"Created: / 11-06-2011 / 23:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 10-08-2011 / 13:18:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!CharacterArray class methodsFor:'accessing-java'!
javaComponentClass
@@ -1036,6 +542,27 @@
"Created: / 20-12-2010 / 22:05:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
+!Class methodsFor:'accessing - java'!
+
+javaMirror
+ ^self javaMirrorClass forClass: self.
+
+ "Created: / 31-07-2012 / 17:39:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Class methodsFor:'accessing - java'!
+
+javaMirrorClass
+ ^self isJavaPrimitiveType ifTrue:[
+ JavaMirror mirrorClassForJavaPrimitive
+ ] ifFalse:[
+ JavaMirror mirrorClassForAlienClass
+ ]
+
+ "Created: / 31-07-2012 / 17:39:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!ConfigurableFeatures class methodsFor:'queries-features'!
hasJavaSupport
@@ -1050,12 +577,67 @@
"Created: / 03-01-2012 / 15:36:03 / cg"
"Created: / 18-02-2012 / 16:42:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
+!Delay methodsFor:'delaying'!
+
+waitWithState:state
+ "suspend the current process until either the relative time delta
+ has passed (if millisecondDelta is non-nil), or the absolute millisecondTime
+ has been reached (if resumptionTime non-nil)."
+
+ | wasBlocked currentDelta dueTime now then |
+ isInterrupted := false.
+ millisecondDelta notNil ifTrue: [
+ now := OperatingSystem getMillisecondTime.
+ currentDelta := millisecondDelta rounded.
+ currentDelta > 16r0fffffff ifTrue: [
+ "NOTE: the microsecondTime is increasing monotonically,
+ while millisecondTime is wrapping at 16r1fffffff.
+ So use the microsecondTime to check when we are finished"
+ dueTime := OperatingSystem getMicrosecondTime + (currentDelta * 1000).
+ currentDelta := 16r0fffffff.
+ ].
+ then := OperatingSystem millisecondTimeAdd: now and: currentDelta.
+ ] ifFalse: [ then := resumptionTime. ].
+ wasBlocked := OperatingSystem blockInterrupts.
+ [
+ [
+ Processor signal: delaySemaphore atMilliseconds: then.
+ Processor activeProcess state: state.
+ delaySemaphore wait.
+ ] doWhile: [
+ (dueTime notNil
+ and: [
+ isInterrupted not
+ and: [ (currentDelta := dueTime - OperatingSystem getMicrosecondTime) > 0 ]
+ ])
+ ifTrue: [
+ currentDelta := (currentDelta // 1000) min: 16r0fffffff.
+ now := OperatingSystem getMillisecondTime.
+ then := OperatingSystem millisecondTimeAdd: now and: currentDelta.
+ true.
+ ]
+ ifFalse: [ false ]
+ ].
+ ] ensure: [ wasBlocked ifFalse: [ OperatingSystem unblockInterrupts ]. ]
+
+ "
+ Transcript showCR:'1'.
+ (Delay forSeconds:10) wait.
+ Transcript showCR:'2'."
+
+ "Modified: / 26-02-1997 / 15:21:35 / cg"
+ "Modified: / 18-04-1997 / 11:56:46 / stefan"
+ "Created: / 30-11-2011 / 13:38:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
!DoubleArray class methodsFor:'testing'!
isInterface
^false
! !
+
!DoubleArray class methodsFor:'queries'!
isJavaArrayClass
@@ -1064,6 +646,7 @@
"Created: / 20-12-2010 / 22:47:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!DoubleArray class methodsFor:'queries'!
isJavaReferenceType
@@ -1073,6 +656,7 @@
"Created: / 20-12-2010 / 22:30:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!DoubleArray class methodsFor:'accessing-java'!
javaArrayClass
@@ -1080,6 +664,7 @@
"Created: / 06-12-2011 / 17:28:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
+
!DoubleArray class methodsFor:'accessing-java'!
javaComponentClass
@@ -1088,6 +673,7 @@
"Created: / 20-12-2010 / 22:06:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!DoubleArray class methodsFor:'accessing'!
javaName
@@ -1096,6 +682,15 @@
"Modified: / 25-02-2011 / 19:03:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
+!ExecutableFunction methodsFor:'queries'!
+
+isJavaConstructor
+ ^ false
+
+ "Created: / 31-07-2012 / 18:42:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!Float class methodsFor:'queries'!
isJavaPrimitiveType
@@ -1104,6 +699,7 @@
"Created: / 06-02-2011 / 17:21:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Float class methodsFor:'accessing'!
javaArrayClass
@@ -1111,6 +707,7 @@
"Created: / 11-02-2011 / 10:50:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Float class methodsFor:'autoboxing support'!
javaBox: anObject
@@ -1122,6 +719,7 @@
"Created: / 16-08-2011 / 09:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Float class methodsFor:'accessing'!
javaName
@@ -1130,6 +728,7 @@
"Modified: / 25-02-2011 / 18:59:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Float class methodsFor:'accessing'!
javaWrapperClass
@@ -1137,12 +736,14 @@
"Created: / 24-02-2012 / 19:42:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!FloatArray class methodsFor:'testing'!
isInterface
^false
! !
+
!FloatArray class methodsFor:'queries'!
isJavaArrayClass
@@ -1151,6 +752,7 @@
"Created: / 20-12-2010 / 22:47:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!FloatArray class methodsFor:'queries'!
isJavaReferenceType
@@ -1160,6 +762,7 @@
"Created: / 20-12-2010 / 22:30:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!FloatArray class methodsFor:'accessing-java'!
javaArrayClass
@@ -1167,6 +770,7 @@
"Created: / 06-12-2011 / 17:29:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
+
!FloatArray class methodsFor:'accessing-java'!
javaComponentClass
@@ -1175,6 +779,7 @@
"Created: / 20-12-2010 / 22:06:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!FloatArray class methodsFor:'accessing'!
javaName
@@ -1183,6 +788,7 @@
"Modified: / 25-02-2011 / 19:03:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Integer class methodsFor:'queries'!
isJavaPrimitiveType
@@ -1191,6 +797,7 @@
"Created: / 11-02-2011 / 11:12:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Integer class methodsFor:'accessing'!
javaArrayClass
@@ -1198,6 +805,7 @@
"Created: / 11-02-2011 / 10:51:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Integer class methodsFor:'autoboxing support'!
javaBox: anObject
@@ -1209,6 +817,7 @@
"Created: / 16-08-2011 / 09:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Integer class methodsFor:'accessing'!
javaName
@@ -1217,6 +826,7 @@
"Modified: / 25-02-2011 / 18:59:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Integer class methodsFor:'autoboxing support'!
javaUnbox: object onError: errorBlock
@@ -1227,6 +837,7 @@
"Created: / 25-11-2011 / 19:10:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Integer class methodsFor:'autoboxing support'!
javaUnbox: object onError: errorBlock min: min max: max
@@ -1248,6 +859,7 @@
"Created: / 22-11-2011 / 11:43:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Integer class methodsFor:'accessing'!
javaWrapperClass
@@ -1255,6 +867,7 @@
"Created: / 24-02-2012 / 19:41:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!LargeInteger class methodsFor:'queries'!
isJavaPrimitiveType
@@ -1263,6 +876,7 @@
"Created: / 04-02-2011 / 11:55:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!LargeInteger class methodsFor:'accessing'!
javaArrayClass
@@ -1270,6 +884,7 @@
"Created: / 11-02-2011 / 10:51:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!LargeInteger class methodsFor:'autoboxing support'!
javaBox: anObject
@@ -1281,6 +896,7 @@
"Created: / 16-08-2011 / 09:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!LargeInteger class methodsFor:'accessing'!
javaName
@@ -1289,6 +905,7 @@
"Modified: / 25-02-2011 / 18:59:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!LargeInteger class methodsFor:'autoboxing support'!
javaUnbox: object onError: errorBlock
@@ -1307,6 +924,7 @@
"Created: / 22-11-2011 / 11:45:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!LargeInteger class methodsFor:'accessing'!
javaWrapperClass
@@ -1314,6 +932,102 @@
"Created: / 24-02-2012 / 19:42:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
+!Object methodsFor:'testing'!
+
+isGroovyClass
+ ^false
+
+ "Created: / 18-02-2012 / 20:29:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Object methodsFor:'testing'!
+
+isJavaArray
+
+ ^self class isJavaArrayClass
+
+ "Created: / 19-12-2010 / 17:05:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Object methodsFor:'testing'!
+
+isJavaNameAndType
+ "return true, if given object represents name and type struct in java constant pool"
+
+ ^ false.
+
+ "Created: / 10-05-2011 / 12:21:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!Object methodsFor:'testing'!
+
+isJavaPackage
+ "return true, if the receiver is a java package.
+ False is returned here - the method is only redefined in JavaPackage."
+
+ ^ false
+
+ "Created: / 09-08-2011 / 09:35:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Object methodsFor:'testing'!
+
+isJavaRef
+"return true, if given object represents reference in java constant pool"
+^ false.
+
+ "Created: / 08-04-2011 / 16:12:45 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!Object methodsFor:'testing'!
+
+isJavaWrapperClass
+ "return true, if this is a java wrapper class, i.e, java.lang.Integer, java.lang.Boolean etc."
+
+ ^ false
+
+ "Created: / 01-01-2012 / 17:25:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Object methodsFor:'autoboxing support'!
+
+javaBox: anObject
+
+ ^anObject
+
+ "Created: / 15-08-2011 / 10:52:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Object methodsFor:'autoboxing support'!
+
+javaUnwrap: anObject
+ "Unwraps the objects. Possibly call on the wrapped class"
+
+ ^anObject
+
+ "Created: / 10-12-2011 / 19:51:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!Object methodsFor:'autoboxing support'!
+
+javaUnwrapFrom: javaType
+ ^ self.
+
+ "Created: / 10-12-2011 / 19:51:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 30-12-2011 / 15:22:06 / kursjan <kursjan@fit.cvut.cz>"
+! !
+
+!Object methodsFor:'autoboxing support'!
+
+javaWrap: anObject
+ "Wraps the receiver into corresponding Java object"
+
+ ^anObject
+
+ "Created: / 26-12-2011 / 00:57:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!Object class methodsFor:'queries'!
isJavaArrayClass
@@ -1322,6 +1036,7 @@
"Created: / 19-12-2010 / 17:05:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Object class methodsFor:'queries'!
isJavaClassType
@@ -1330,6 +1045,7 @@
"Created: / 11-02-2011 / 08:08:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Object class methodsFor:'queries'!
isJavaPrimitiveType
@@ -1338,6 +1054,7 @@
"Created: / 20-12-2010 / 21:52:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Object class methodsFor:'queries'!
isJavaReferenceType
@@ -1346,6 +1063,7 @@
"Created: / 20-12-2010 / 21:52:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!Object class methodsFor:'queries'!
isJavaType
@@ -1354,6 +1072,99 @@
"Created: / 20-12-2010 / 21:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
+!Process methodsFor:'Java protocol'!
+
+clearInterrupted
+ JavaVM threadInterrupts at: self put: false.
+
+ "Created: / 30-11-2011 / 10:44:26 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!Process methodsFor:'Java protocol'!
+
+isInterrupted
+
+ ^ JavaVM threadInterrupts at: self
+ ifAbsent: [ JavaVM threadInterrupts at: self put: false. ]
+
+ "Created: / 30-11-2011 / 12:12:33 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!Process methodsFor:'queries'!
+
+isSleeping
+ "return true, iff the receiver is sleeping on Delay"
+
+ ^ (state == #sleep)
+
+ "Created: / 30-11-2011 / 13:35:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!Process methodsFor:'queries'!
+
+isWaiting
+ "return true, iff the receiver is waiting on semaphore or something"
+
+ ^ (state == #wait)
+
+ "Created: / 20-11-2011 / 20:55:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!Process methodsFor:'Java protocol'!
+
+javaInterrupt
+ self isWaiting ifTrue: [
+ self
+ interruptWith: [
+ JavaVM
+ throwInterruptedException: 'thread has been interrupted during wait'.
+ self terminate
+ ]
+ ] ifFalse: [
+ self isSleeping ifTrue: [
+
+ self
+ interruptWith: [
+ JavaVM
+ throwInterruptedException: 'thread has been interrupted during sleep'.
+ self terminate
+ ]
+ ] ifFalse: [ self setInterrupted. ]
+ ]
+
+ "Created: / 30-11-2011 / 13:35:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!Process methodsFor:'Java protocol'!
+
+setInterrupted
+
+ JavaVM threadInterrupts at: self put: true.
+
+ "Created: / 30-11-2011 / 10:44:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!ProgrammingLanguage methodsFor:'testing'!
+
+isGroovy
+ "true iff this is a Groovy language"
+
+ ^ false
+
+ "Created: / 13-04-2012 / 17:47:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ProgrammingLanguage methodsFor:'testing'!
+
+isJavaLike
+ "true if receiver is kind of Java language (based on Java)"
+
+ ^ false
+
+ "Created: / 13-04-2012 / 17:48:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!ProjectDefinition class methodsFor:'description - java'!
javaClassPath
@@ -1365,6 +1176,7 @@
"Created: / 13-12-2011 / 23:48:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!ProjectDefinition class methodsFor:'description - java'!
javaSourcePath
@@ -1375,6 +1187,13 @@
"Created: / 13-12-2011 / 23:49:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
+!Set methodsFor:'javaProtocol'!
+
+java__contains:anObject
+ ^ self contains: [:el | anObject = el ]
+! !
+
!ShortFloat class methodsFor:'queries'!
isJavaPrimitiveType
@@ -1383,6 +1202,7 @@
"Created: / 06-02-2011 / 17:21:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!ShortFloat class methodsFor:'accessing'!
javaArrayClass
@@ -1390,6 +1210,7 @@
"Created: / 11-02-2011 / 10:50:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!ShortFloat class methodsFor:'autoboxing support'!
javaBox: anObject
@@ -1401,6 +1222,7 @@
"Created: / 16-08-2011 / 09:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!ShortFloat class methodsFor:'accessing'!
javaName
@@ -1409,6 +1231,7 @@
"Modified: / 25-02-2011 / 18:59:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!ShortFloat class methodsFor:'accessing'!
javaWrapperClass
@@ -1416,12 +1239,14 @@
"Created: / 24-02-2012 / 19:42:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedIntegerArray class methodsFor:'testing'!
isInterface
^false
! !
+
!SignedIntegerArray class methodsFor:'queries'!
isJavaArrayClass
@@ -1430,6 +1255,7 @@
"Created: / 06-02-2011 / 15:16:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedIntegerArray class methodsFor:'accessing-java'!
javaArrayClass
@@ -1439,6 +1265,7 @@
"Created: / 11-06-2011 / 23:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 10-08-2011 / 22:47:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedIntegerArray class methodsFor:'accessing'!
javaComponentClass
@@ -1447,6 +1274,7 @@
"Created: / 25-06-2011 / 08:38:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedIntegerArray class methodsFor:'accessing'!
javaName
@@ -1455,12 +1283,14 @@
"Modified: / 25-02-2011 / 19:03:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedLongIntegerArray class methodsFor:'testing'!
isInterface
^false
! !
+
!SignedLongIntegerArray class methodsFor:'queries'!
isJavaArrayClass
@@ -1469,6 +1299,7 @@
"Created: / 20-12-2010 / 22:47:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedLongIntegerArray class methodsFor:'queries'!
isJavaReferenceType
@@ -1478,6 +1309,7 @@
"Created: / 20-12-2010 / 22:30:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedLongIntegerArray class methodsFor:'accessing-java'!
javaArrayClass
@@ -1487,6 +1319,7 @@
"Modified: / 10-08-2011 / 22:47:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Created: / 26-08-2011 / 18:29:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedLongIntegerArray class methodsFor:'accessing'!
javaComponentClass
@@ -1495,6 +1328,7 @@
"Modified: / 25-06-2011 / 08:38:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedLongIntegerArray class methodsFor:'accessing'!
javaName
@@ -1503,6 +1337,7 @@
"Modified: / 25-02-2011 / 19:03:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedWordArray class methodsFor:'queries'!
isJavaArrayClass
@@ -1511,6 +1346,7 @@
"Created: / 20-12-2010 / 22:47:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedWordArray class methodsFor:'queries'!
isJavaReferenceType
@@ -1520,6 +1356,7 @@
"Created: / 20-12-2010 / 22:30:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedWordArray class methodsFor:'accessing'!
javaComponentClass
@@ -1528,6 +1365,7 @@
"Modified: / 24-02-2012 / 17:46:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!SignedWordArray class methodsFor:'accessing'!
javaName
@@ -1536,6 +1374,44 @@
"Modified: / 24-02-2012 / 17:46:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
+!SmallInteger methodsFor:'autoboxing'!
+
+javaUnwrapFrom: javaType
+ javaType = #boolean ifTrue: [
+ ^ self = 1
+ ].
+ ^ self
+
+ "Created: / 30-12-2011 / 15:22:52 / kursjan <kursjan@fit.cvut.cz>"
+! !
+
+!String methodsFor:'converting'!
+
+asArrayOfSubstringsSeparatedBy:aSeparator
+ "Modified version of asArrayOfSubstrings"
+
+ |substrings start end|
+
+ substrings := OrderedCollection new.
+ start := 1.
+ [start <= self size] whileTrue:[
+ (self at:start) = aSeparator ifFalse:[
+ end := start + 1.
+ [
+ end <= self size and:[(self at:end) ~= aSeparator]
+ ] whileTrue:[end := end + 1].
+ substrings add:(self copyFrom:start to:end - 1).
+ start := end - 1
+ ].
+ start := start + 1
+ ].
+ ^ substrings asArray
+
+ "Created: / 07-02-2011 / 11:18:03 / Marcel Hlopko <hlopik@gmail.com>"
+ "Modified: / 08-02-2011 / 01:08:15 / Marcel Hlopko <hlopik@gmail.com>"
+! !
+
!UndefinedObject class methodsFor:'queries'!
isJavaPrimitiveType
@@ -1546,6 +1422,7 @@
"Created: / 21-12-2010 / 22:52:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!UndefinedObject class methodsFor:'accessing'!
javaName
@@ -1554,12 +1431,240 @@
"Modified: / 25-02-2011 / 18:59:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
+!UserPreferences methodsFor:'accessing-java'!
+
+javaClassPath
+ "Return the Java user-defined class path encoded as literal array"
+
+ ^ self at:#javaClassPath ifAbsent:[#()].
+
+ "
+ UserPreferences current javaClassPath
+ UserPreferences current javaClassPath: #openJDK7
+
+ Java classPath
+ "
+
+ "Created: / 27-07-2012 / 12:52:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-java'!
+
+javaClassPath: literalArrayEncoding
+ "Sets the Java user-defined class path as literalArrayEncoding of a collection
+ of JavaPathElements"
+
+ self at:#javaClassPath put: literalArrayEncoding.
+ (Java notNil and:[thisContext sender receiver == Java]) ifFalse:[
+ | classPath |
+ classPath := literalArrayEncoding decodeAsLiteralArray.
+ Java classPath: classPath.
+ ].
+
+
+ "
+ UserPreferences current javaClassPath
+ UserPreferences current javaClassPath: #openJDK7
+
+ Java classPath
+ "
+
+ "Created: / 27-07-2012 / 12:50:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-java'!
+
+javaClassPathDecoded
+ "Return the Java user-defined class path (a collection of JavaPathElement)"
+
+ ^ self javaClassPath decodeAsLiteralArray
+
+ "
+ UserPreferences current javaClassPathDecoded
+ UserPreferences current javaClassPath
+
+ Java classPath
+ "
+
+ "Created: / 02-08-2012 / 09:43:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-java'!
+
+javaRelease
+ "Return the Java release according to the preferences
+ or nil, if not set"
+
+ | rel sel |
+ sel := self javaReleaseSelector.
+ sel notNil ifTrue:[
+ rel := JavaRelease perform: sel asSymbol ifNotUnderstood:[nil]
+ ].
+ ^rel
+
+ "Created: / 27-07-2012 / 10:12:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-java'!
+
+javaReleaseSelector
+ ^ self at:#javaReleaseSelector ifAbsent:[nil].
+
+ "
+ UserPreferences current javaReleaseSelector
+ UserPreferences current javaReleaseSelector: #openJDK6
+ UserPreferences current javaReleaseSelector: nil
+
+ Java release
+ "
+
+ "Created: / 27-07-2012 / 10:02:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-java'!
+
+javaReleaseSelector: name
+ "Sets the Java release to use. selector must be one of
+ releases defined in JavaRelease, protocol 'instance creation'"
+
+ self at:#javaReleaseSelector put: name.
+ Java notNil ifTrue:[
+ Java reinitializeRelease
+ ].
+
+
+ "
+ UserPreferences current javaReleaseSelector
+ UserPreferences current javaReleaseSelector: #openJDK7
+ UserPreferences current javaReleaseSelector: nil
+
+ Java release
+ Java release:nil
+
+ Java reinitializeRelease
+ "
+
+ "Created: / 27-07-2012 / 10:02:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-java'!
+
+javaSourcePath
+ "Return the Java user-defined source path encoded as literal array"
+
+ ^ self at:#javaSourcePath ifAbsent:[#()].
+
+ "
+ UserPreferences current javaSourcePath
+ UserPreferences current javaSourcePath: #openJDK7
+
+ Java sourcePath
+ "
+
+ "Created: / 27-07-2012 / 12:54:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-java'!
+
+javaSourcePath: literalArrayEncoding
+ "Sets the Java user-defined source path as literalArrayEncoding of a collection
+ of JavaPathElements"
+
+ self at:#javaSourcePath put: literalArrayEncoding.
+ (Java notNil and:[thisContext sender receiver == Java]) ifFalse:[
+ | classPath |
+ classPath := literalArrayEncoding decodeAsLiteralArray.
+ Java sourceDirectories: classPath.
+ ].
+
+
+ "
+ UserPreferences current javaClassPath
+ UserPreferences current javaClassPath: #openJDK7
+
+ Java sourceDirectories
+ "
+
+ "Created: / 27-07-2012 / 12:54:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-java'!
+
+javaSourcePathDecoded
+ "Return the Java user-defined source path (a collection of JavaPathElement)"
+
+ ^ self javaSourcePath decodeAsLiteralArray
+
+ "
+ UserPreferences current javaSourcePathDecoded
+ UserPreferences current javaSourcePath
+
+ Java sourceDirectories
+ "
+
+ "Created: / 02-08-2012 / 09:44:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-java-devel'!
+
+javaTestsDirectory
+ ^ self at: #javaTestsDirectory
+ ifAbsent:
+ [ | nm |
+
+ nm := OperatingSystem getLoginName.
+ "Default path for Jan"
+ (nm = 'jv' and:[OperatingSystem isUNIXlike])
+ ifTrue:
+ [ '/home/jv/Projects/libjava/sources/libjava/branches/jk_new_structure/tests' ]
+ ifFalse:
+ [ "Default path for Jan (the other one :-)"
+ nm = 'jk'
+ ifTrue: [ 'path for Jan' ]
+ ifFalse:
+ [ "Default path for Marcel"
+ nm = 'm'
+ ifTrue: [ '/home/m/Projects/libjava/branches/jk_new_structure/tests' ]
+ ifFalse:
+ [ | "Look into package dir" p |
+
+ (p := (Smalltalk getPackageDirectoryForPackage: 'stx:libjava') asFilename
+ / 'tests') exists
+ ifTrue: [ p pathName ]
+ ifFalse:
+ [ | "Try the environment variable (used by Hudson)" p |
+
+ (p := OperatingSystem getEnvironment: 'LIBJAVA_TESTS') notNil
+ ifTrue: [ p ]
+ ifFalse:
+ [ "No default, trigger an error"
+ self error: 'No tests path specified' ] ] ] ] ] ]
+
+ "
+ UserPreferences current javaTestsDirectory"
+
+ "Created: / 07-05-2011 / 17:43:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 07-05-2011 / 20:21:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 12-05-2011 / 15:54:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!UserPreferences methodsFor:'accessing-java-devel'!
+
+javaTestsDirectory: aStringOrFilename
+
+ self at:#javaTestsDirectory put: aStringOrFilename asString.
+
+ "Created: / 07-05-2011 / 17:45:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!WordArray class methodsFor:'testing'!
isInterface
^false
! !
+
!WordArray class methodsFor:'queries'!
isJavaArrayClass
@@ -1568,6 +1673,7 @@
"Created: / 20-12-2010 / 22:47:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!WordArray class methodsFor:'queries'!
isJavaReferenceType
@@ -1577,6 +1683,7 @@
"Created: / 20-12-2010 / 22:30:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!WordArray class methodsFor:'accessing-java'!
javaArrayClass
@@ -1586,6 +1693,7 @@
"Created: / 11-06-2011 / 23:42:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 10-08-2011 / 22:46:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!WordArray class methodsFor:'accessing-java'!
javaComponentClass
@@ -1594,6 +1702,7 @@
"Created: / 20-12-2010 / 22:13:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+
!WordArray class methodsFor:'accessing'!
javaName
@@ -1601,3 +1710,44 @@
"Modified: / 06-12-2011 / 16:43:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
! !
+
+!WrappedMethod methodsFor:'accessing'!
+
+descriptor
+ "Returns descriptor object (for wrapped Java methods)"
+
+ | orig |
+ orig := self originalMethod.
+ ^(orig respondsTo: #descriptor) ifTrue:[
+ orig descriptor
+ ] ifFalse:[
+ self doesNotUnderstand: (Message selector: #descriptor)
+ ]
+
+ "Created: / 16-12-2011 / 20:03:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!WrappedMethod methodsFor:'queries'!
+
+isAbstract
+
+ ^self originalMethod isAbstract.
+
+ "Created: / 04-12-2011 / 11:24:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ZipArchive methodsFor:'reading - java support'!
+
+nextBytes: bytesToRead of: zmember startingAt: pos into: b startingAt: off
+
+ file position0Based: zmember fileStart + startOfArchive + pos.
+ ^ file nextBytes: bytesToRead into: b startingAt: off.
+
+ "Created: / 01-05-2011 / 16:21:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!stx_libjava class methodsFor:'documentation'!
+
+extensionsVersion_SVN
+ ^ '$Id:: $'
+! !
\ No newline at end of file