src/JavaVM.st
branchjk_new_structure
changeset 880 a9171dcee2b0
parent 877 f5a5b93e1c78
child 881 e45c36ff74fc
equal deleted inserted replaced
879:8bb82d1ea058 880:a9171dcee2b0
  4042 !
  4042 !
  4043 
  4043 
  4044 _java_lang_ClassLoader_defineClass1: nativeContext
  4044 _java_lang_ClassLoader_defineClass1: nativeContext
  4045 
  4045 
  4046     <javanative: 'java/lang/ClassLoader' name: 'defineClass1'>
  4046     <javanative: 'java/lang/ClassLoader' name: 'defineClass1'>
  4047 
  4047     "
  4048     ^ UnimplementedNativeMethodSignal raise
  4048     private native Class defineClass1(String name, byte[] b, int off, int len,
       
  4049                                       ProtectionDomain pd, String source);
       
  4050     "
       
  4051     | name b off len pd source bs cls |
       
  4052     name :=  Java as_ST_String: (nativeContext argAt:1).
       
  4053     b := nativeContext argAt:2.
       
  4054     off := nativeContext argAt:3.
       
  4055     len := nativeContext argAt:4.
       
  4056     pd := nativeContext argAt:5.
       
  4057     source := Java as_ST_String: (nativeContext argAt:6).
       
  4058 
       
  4059     bs := (off = 0 and: [len = b size]) 
       
  4060             ifTrue:[b readStream]
       
  4061             ifFalse:[(b copyFrom: off + 1 to: off + len) readStream].
       
  4062 
       
  4063     cls := JavaClassReader readStream: bs.
       
  4064     cls classLoader: nativeContext receiver.
       
  4065     "FIXME: What to do with source?"
       
  4066 
       
  4067     ^self reflection javaClassObjectForClass: cls.
       
  4068 
       
  4069     "Modified (comment): / 05-08-2011 / 18:37:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  4049 !
  4070 !
  4050 
  4071 
  4051 _java_lang_ClassLoader_findLoadedClass0: nativeContext
  4072 _java_lang_ClassLoader_findLoadedClass0: nativeContext
  4052 
  4073 
  4053     <javanative: 'java/lang/ClassLoader' name: 'findLoadedClass0'>
  4074     <javanative: 'java/lang/ClassLoader' name: 'findLoadedClass0'>
  5496 !JavaVM class methodsFor:'native - java.util.jar'!
  5517 !JavaVM class methodsFor:'native - java.util.jar'!
  5497 
  5518 
  5498 _java_util_jar_JarFile_getMetaInfEntryNames: nativeContext
  5519 _java_util_jar_JarFile_getMetaInfEntryNames: nativeContext
  5499 
  5520 
  5500     <javanative: 'java/util/jar/JarFile' name: 'getMetaInfEntryNames'>
  5521     <javanative: 'java/util/jar/JarFile' name: 'getMetaInfEntryNames'>
  5501 
  5522     "
  5502     ^ UnimplementedNativeMethodSignal raise
  5523     private native String[] getMetaInfEntryNames();
       
  5524     "
       
  5525     | zipArchive entries  |
       
  5526 
       
  5527     zipArchive := ZipCache at: (nativeContext receiver instVarNamed: #jzfile).
       
  5528     entries := zipArchive entries select:[:entry|entry size > 9 and:[entry startsWith: 'META-INF/']].    entries := entries collect:[:entry|Java as_String: entry].
       
  5529     ^entries
       
  5530 
       
  5531     "Modified: / 05-08-2011 / 19:27:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  5503 ! !
  5532 ! !
  5504 
  5533 
  5505 !JavaVM class methodsFor:'native - java.util.zip'!
  5534 !JavaVM class methodsFor:'native - java.util.zip'!
  5506 
  5535 
  5507 _java_util_zip_Adler32_updateBytes: nativeContext
  5536 _java_util_zip_Adler32_updateBytes: nativeContext
 13655 !
 13684 !
 13656 
 13685 
 13657 _sun_reflect_NativeMethodAccessorImpl_invoke0: nativeContext
 13686 _sun_reflect_NativeMethodAccessorImpl_invoke0: nativeContext
 13658 
 13687 
 13659     <javanative: 'sun/reflect/NativeMethodAccessorImpl' name: 'invoke0'>
 13688     <javanative: 'sun/reflect/NativeMethodAccessorImpl' name: 'invoke0'>
 13660 
 13689     "
 13661         "
       
 13662     private static native Object invoke0(Method m, Object obj, Object[] args);
 13690     private static native Object invoke0(Method m, Object obj, Object[] args);
 13663     "
 13691     "
 13664     | m obj args |
 13692     | m obj args method adescriptors uargs |
 13665     m := nativeContext argAt: 1.
 13693     m := nativeContext argAt: 1.
 13666     obj := nativeContext argAt: 2.
 13694     obj := nativeContext argAt: 2.
 13667     args := nativeContext argAt: 3.
 13695     args := nativeContext argAt: 3.
 13668 
 13696 
 13669     ^(self reflection methodForJavaMethodObject: m) 
 13697     method := self reflection methodForJavaMethodObject: m.
       
 13698 
       
 13699     "Possibly unbox arguments"
       
 13700     args notEmptyOrNil ifTrue:[
       
 13701         adescriptors := (JavaDescriptor fromString: method signature) parameters.
       
 13702         uargs := Array new: args size.
       
 13703         1 to: args size do:[:i|
       
 13704             uargs at: i put: ((adescriptors at: i) javaClass javaUnbox: (args at:i))
       
 13705         ].
       
 13706     ] ifFalse:[
       
 13707         uargs := #()
       
 13708     ].
       
 13709     "Fire the method"
       
 13710     ^method
 13670         valueWithReceiver: obj
 13711         valueWithReceiver: obj
 13671         arguments: (args ? #()) asArray.
 13712         arguments: uargs
 13672 
 13713 
 13673     "Created: / 06-02-2011 / 00:00:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 13714     "Created: / 06-02-2011 / 00:00:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 13674     "Modified: / 28-02-2011 / 16:57:31 / Marcel Hlopko <hlopik@gmail.com>"
 13715     "Modified: / 28-02-2011 / 16:57:31 / Marcel Hlopko <hlopik@gmail.com>"
 13675     "Modified: / 16-03-2011 / 15:31:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 13716     "Modified: / 05-08-2011 / 19:13:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 13676 !
 13717 !
 13677 
 13718 
 13678 _sun_reflect_Reflection_getCallerClass: aJavaContext
 13719 _sun_reflect_Reflection_getCallerClass: aJavaContext
 13679 
 13720 
 13680     <javanative: 'sun/reflect/Reflection' name: 'getCallerClass'>
 13721     <javanative: 'sun/reflect/Reflection' name: 'getCallerClass'>