JavaNativeMethodImpl_OpenJDK7.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 24 May 2013 17:55:42 +0100
branchbuiltin-class-support
changeset 2629 cedb88626902
parent 2548 3c51f38da021
child 2711 a00302fe5083
permissions -rw-r--r--
Closing branch.

"
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libjava' }"

JavaNativeMethodImpl_OpenJDK6 subclass:#JavaNativeMethodImpl_OpenJDK7
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:'JavaVMData'
	category:'Languages-Java-Support-OpenJDK7'
!

!JavaNativeMethodImpl_OpenJDK7 class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
! !

!JavaNativeMethodImpl_OpenJDK7 class methodsFor:'native - java.io'!

_java_io_FileOutputStream_open: this _: a1 _: a2 

    <javanative: 'java/io/FileOutputStream' name: 'open(Ljava/lang/String;Z)V'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_FileOutputStream_write: this _: a1 _: a2 

    <javanative: 'java/io/FileOutputStream' name: 'write(IZ)V'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_FileOutputStream_writeBytes: this _:bytes _: offset _: count _: append

    <javanative: 'java/io/FileOutputStream' name: 'writeBytes([BIIZ)V'>

    ^ self anyStream_write: this bytes: bytes offset: offset count: count append: append == 1.

    "Modified: / 08-02-2013 / 11:57:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_io_UnixFileSystem_createFileExclusively: this _: a1 

    <javanative: 'java/io/UnixFileSystem' name: 'createFileExclusively(Ljava/lang/String;)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_canonicalize0: this _: a1 

    <javanative: 'java/io/Win32FileSystem' name: 'canonicalize0(Ljava/lang/String;)Ljava/lang/String;'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_canonicalizeWithPrefix0: this _: a1 _: a2 

    <javanative: 'java/io/Win32FileSystem' name: 'canonicalizeWithPrefix0(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_checkAccess: this _: a1 _: a2 

    <javanative: 'java/io/Win32FileSystem' name: 'checkAccess(Ljava/io/File;I)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_createDirectory: this _: a1 

    <javanative: 'java/io/Win32FileSystem' name: 'createDirectory(Ljava/io/File;)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_createFileExclusively: this _: a1 

    <javanative: 'java/io/Win32FileSystem' name: 'createFileExclusively(Ljava/lang/String;)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_delete0: this _: a1 

    <javanative: 'java/io/Win32FileSystem' name: 'delete0(Ljava/io/File;)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_getBooleanAttributes: this _: a1 

    <javanative: 'java/io/Win32FileSystem' name: 'getBooleanAttributes(Ljava/io/File;)I'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_getDriveDirectory: this _: a1 

    <javanative: 'java/io/Win32FileSystem' name: 'getDriveDirectory(I)Ljava/lang/String;'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_getLastModifiedTime: this _: a1 

    <javanative: 'java/io/Win32FileSystem' name: 'getLastModifiedTime(Ljava/io/File;)J'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_getLength: this _: a1 

    <javanative: 'java/io/Win32FileSystem' name: 'getLength(Ljava/io/File;)J'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_getSpace0: this _: a1 _: a2 

    <javanative: 'java/io/Win32FileSystem' name: 'getSpace0(Ljava/io/File;I)J'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_list: this _: a1 

    <javanative: 'java/io/Win32FileSystem' name: 'list(Ljava/io/File;)[Ljava/lang/String;'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_listRoots0: this 

    <javanative: 'java/io/Win32FileSystem' name: 'listRoots0()I'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_rename0: this _: a1 _: a2 

    <javanative: 'java/io/Win32FileSystem' name: 'rename0(Ljava/io/File;Ljava/io/File;)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_setLastModifiedTime: this _: a1 _: a2 _: a3 

    <javanative: 'java/io/Win32FileSystem' name: 'setLastModifiedTime(Ljava/io/File;J)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_setPermission: this _: a1 _: a2 _: a3 _: a4 

    <javanative: 'java/io/Win32FileSystem' name: 'setPermission(Ljava/io/File;IZZ)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_Win32FileSystem_setReadOnly: this _: a1 

    <javanative: 'java/io/Win32FileSystem' name: 'setReadOnly(Ljava/io/File;)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_WinNTFileSystem_getDriveDirectory: this _: a1 

    <javanative: 'java/io/WinNTFileSystem' name: 'getDriveDirectory(I)Ljava/lang/String;'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_WinNTFileSystem_getSpace0: this _: a1 _: a2 

    <javanative: 'java/io/WinNTFileSystem' name: 'getSpace0(Ljava/io/File;I)J'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_WinNTFileSystem_initIDs: this 

    <javanative: 'java/io/WinNTFileSystem' name: 'initIDs()V'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_WinNTFileSystem_rename0: this _: a1 _: a2 

    <javanative: 'java/io/WinNTFileSystem' name: 'rename0(Ljava/io/File;Ljava/io/File;)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_WinNTFileSystem_setLastModifiedTime: this _: a1 _: a2 _: a3 

    <javanative: 'java/io/WinNTFileSystem' name: 'setLastModifiedTime(Ljava/io/File;J)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_WinNTFileSystem_setPermission: this _: a1 _: a2 _: a3 _: a4 

    <javanative: 'java/io/WinNTFileSystem' name: 'setPermission(Ljava/io/File;IZZ)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_io_WinNTFileSystem_setReadOnly: this _: a1 

    <javanative: 'java/io/WinNTFileSystem' name: 'setReadOnly(Ljava/io/File;)Z'>

    ^ JavaVM unimplementedNativeMethodSignal raise
! !

!JavaNativeMethodImpl_OpenJDK7 class methodsFor:'native - java.lang'!

_java_lang_ClassLoader_getCaller: this _: a1 

    <javanative: 'java/lang/ClassLoader' name: 'getCaller(I)Ljava/lang/Class;'>

    "/ index 0: java.lang.ClassLoader.class
    "/ index 1: the immediate caller of index 0.
    "/ index 2: the immediate caller of index 1.

    | ctx |

    ctx := self nativeContext sender.
    a1 timesRepeat:[
        ctx := ctx sender
    ].
    ^JavaVM reflection javaClassObjectForClass: ctx receiver class theNonMetaclass

    "Modified: / 07-02-2013 / 23:35:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_lang_Thread_setNativeName: this _: a1 

    <javanative: 'java/lang/Thread' name: 'setNativeName(Ljava/lang/String;)V'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_java_lang_Throwable_fillInStackTrace: this _: a1 

    <javanative: 'java/lang/Throwable' name: 'fillInStackTrace(I)Ljava/lang/Throwable;'>

    | java_lang_Throwable  exceptionObject  list  con |

    java_lang_Throwable := Java classNamed: 'java/lang/Throwable'.
    exceptionObject := this.

    "/
    "/ debugging only
    "/

    (java_lang_Throwable notNil and:[(exceptionObject isKindOf: java_lang_Throwable) not]) ifTrue: [
        self error:'Thrown object is not a java.lang.Throwable'.
    ].
    con := self nativeContext sender.
    "/ Just a guess, there is no comment what the parameter means...
    a1 timesRepeat: [ con := con sender ].

    "/
    "/ we are not interrested in all intermediate Exception frames ...
    "/

    FullExceptionTrace ifFalse: [
        "/ first, skip any JavaVM contexts
        [ con receiver == exceptionObject ] whileFalse: [ con := con sender ].

        "/ then, all exception-init contexts

        [ con receiver == exceptionObject ] whileTrue: [ con := con sender ].
    ].
    list := OrderedCollection new.
    [ con notNil ] whileTrue: [
        (con isJavaContext) ifTrue: [
            "/ add a copy, in case the context continues with some
            "/ cleanup ...
            list add: con shallowCopy
        ].
        con := con sender
    ].
    exceptionObject instVarNamed: 'backtrace' put: (list asArray).
    ^ nil.

    "Modified: / 08-02-2013 / 01:28:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaNativeMethodImpl_OpenJDK7 class methodsFor:'native - java.util.zip'!

_java_util_zip_ZipFile_getCommentBytes: this _: jzentry _: a2 

    <javanative: 'java/util/zip/ZipFile' name: 'getCommentBytes(J)[B'>

    |  zmember |

    zmember := ZipEntryCache at: jzentry.
    ^zmember fileComment asByteArray

    "Modified: / 08-02-2013 / 09:46:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_util_zip_ZipFile_getEntry: this _: a1 _: a2 _: a3 _: a4 

    <javanative: 'java/util/zip/ZipFile' name: 'getEntry(J[BZ)J'>
    "
    !!!!!!WARNING!!!!!!!!
    In Open JDK 7, it takes byte array instead of string like in Open JDK 6!!!!!!!!
    "

    | zipArchive  filename  member |

    zipArchive := self getZipArchiveAt:a1.
    filename := a3 asString.
    member := (zipArchive findMemberAllowForMissingTrailingSlash: filename).
    member isNil ifTrue: [
        ^ 0
    ] ifFalse: [
        ^ ZipEntryCache indexOf: member ifAbsent:[
            ZipEntryCache add: member.
            ZipEntryCache size.
        ]
    ]

    "Modified: / 11-02-2013 / 12:45:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_util_zip_ZipFile_getEntryBytes: this _: jzentry _: a2 _: type 

    <javanative: 'java/util/zip/ZipFile' name: 'getEntryBytes(JI)[B'>

    |  zmember |

    zmember := ZipEntryCache at: jzentry.
    type == 1 "JZENTRY_EXTRA" ifTrue:[
        ^zmember extraFieldLength == 0
            ifTrue:[nil]
            ifFalse:[zmember extraField asByteArray].
    ].
    type == 2 "JZENTRY_COMMENT" ifTrue:[
        ^zmember fileCommentLength == 0
            ifTrue:[nil]
            ifFalse:[zmember fileComment asByteArray].
    ].
    self breakPoint: #jv.
    JavaVM throwZipException: 'Unknown type in getEntryBytes()'.

    "Modified: / 08-02-2013 / 09:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_util_zip_ZipFile_getEntryCSize: this _: jzentry _: a2 

    <javanative: 'java/util/zip/ZipFile' name: 'getEntryCSize(J)J'>

    |  zmember |

    zmember := ZipEntryCache at: jzentry.
    ^zmember compressedSize

    "Modified: / 08-02-2013 / 09:44:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_util_zip_ZipFile_getEntryCrc: this _: jzentry _: a2 

    <javanative: 'java/util/zip/ZipFile' name: 'getEntryCrc(J)J'>

    |  zmember |

    zmember := ZipEntryCache at: jzentry.
    ^zmember crc32

    "Modified: / 08-02-2013 / 09:45:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_util_zip_ZipFile_getEntryFlag: this _: jzentry _: a2 

    <javanative: 'java/util/zip/ZipFile' name: 'getEntryFlag(J)I'>

    |  zmember |

    zmember := ZipEntryCache at: jzentry.
    ^zmember generalPurposBitFlag

    "Modified: / 08-02-2013 / 09:42:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_util_zip_ZipFile_getEntryMethod: this _: jzentry _: a2 

    <javanative: 'java/util/zip/ZipFile' name: 'getEntryMethod(J)I'>

    |  zmember |

    zmember := ZipEntryCache at: jzentry.
    ^zmember compressionMethod

    "Modified: / 08-02-2013 / 09:44:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_util_zip_ZipFile_getEntrySize: this _: jzentry _: a2 

    <javanative: 'java/util/zip/ZipFile' name: 'getEntrySize(J)J'>

    |  zmember |

    zmember := ZipEntryCache at: jzentry.
    ^zmember uncompressedSize

    "Modified: / 08-02-2013 / 09:43:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_util_zip_ZipFile_getEntryTime: this _: jzentry _: a2 

    <javanative: 'java/util/zip/ZipFile' name: 'getEntryTime(J)J'>

    |  zmember |

    zmember := ZipEntryCache at: jzentry.
    ^zmember lastModFileTime

    "Modified: / 08-02-2013 / 09:45:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_java_util_zip_ZipFile_open: this _: a1 _: a2 _: a3 _: a4 _: usemmap 

    <javanative: 'java/util/zip/ZipFile' name: 'open(Ljava/lang/String;IJZ)J'>

    "No mmap support for zip files yet, use Open JDK 6 implementation"

    ^self _java_util_zip_ZipFile_open: this _: a1 _: a2 _: a3 _: a4

    "Modified: / 23-04-2013 / 10:00:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaNativeMethodImpl_OpenJDK7 class methodsFor:'native - sun.misc'!

_sun_misc_Perf_attach: this _: a1 _: a2 _: a3 

    <javanative: 'sun/misc/Perf' name: 'attach(Ljava/lang/String;II)Ljava/nio/ByteBuffer;'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_sun_misc_Perf_createByteArray: this _: a1 _: a2 _: a3 _: a4 _: a5 

    <javanative: 'sun/misc/Perf' name: 'createByteArray(Ljava/lang/String;II[BI)Ljava/nio/ByteBuffer;'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_sun_misc_Perf_createLong: this _: a1 _: a2 _: a3 _: a4 _: a5 

    <javanative: 'sun/misc/Perf' name: 'createLong(Ljava/lang/String;IIJ)Ljava/nio/ByteBuffer;'>

    | memory |

    memory := JavaVM performance counters at: (Java as_ST_String: a1) ifAbsentPut:[ ByteArray new: 8].
    ^JAVA java nio HeapByteBuffer new: memory with: 0 with: 8.

    "Modified: / 20-02-2013 / 00:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_sun_misc_Perf_detach: this _: a1 

    <javanative: 'sun/misc/Perf' name: 'detach(Ljava/nio/ByteBuffer;)V'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_sun_misc_Perf_highResCounter: this 

    <javanative: 'sun/misc/Perf' name: 'highResCounter()J'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_sun_misc_Perf_highResFrequency: this 

    <javanative: 'sun/misc/Perf' name: 'highResFrequency()J'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_sun_misc_Perf_registerNatives: this 

    <javanative: 'sun/misc/Perf' name: 'registerNatives()V'>

    "Nothing to do here"

    "Modified: / 11-02-2013 / 02:53:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

_sun_misc_Unsafe_copyMemory: this _: a1 _: a2 _: a3 _: a4 _: a5 _: a6 _: a7 _: a8 

    <javanative: 'sun/misc/Unsafe' name: 'copyMemory(Ljava/lang/Object;JLjava/lang/Object;JJ)V'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_sun_misc_Unsafe_defineAnonymousClass: this _: a1 _: a2 _: a3 

    <javanative: 'sun/misc/Unsafe' name: 'defineAnonymousClass(Ljava/lang/Class;[B[Ljava/lang/Object;)Ljava/lang/Class;'>

    ^ JavaVM unimplementedNativeMethodSignal raise
!

_sun_misc_Unsafe_setMemory: this _: a1 _: a2 _: a3 _: a4 _: a5 _: a6 

    <javanative: 'sun/misc/Unsafe' name: 'setMemory(Ljava/lang/Object;JJB)V'>

    ^ JavaVM unimplementedNativeMethodSignal raise
! !

!JavaNativeMethodImpl_OpenJDK7 class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libjava/JavaNativeMethodImpl_OpenJDK7.st,v 1.2 2013-02-25 11:15:31 vrany Exp $'
!

version_HG

    ^ '$Changeset: <not expanded> $'
! !