This commit is contained in:
jfrijters 2004-08-30 15:56:23 +00:00
Родитель 75d9c616f9
Коммит c42d54eff8
34 изменённых файлов: 4852 добавлений и 4733 удалений

Просмотреть файл

@ -10,6 +10,7 @@ java/lang/VMThread.java
java/lang/VMClass.java java/lang/VMClass.java
java/lang/VMDouble.java java/lang/VMDouble.java
java/lang/VMFloat.java java/lang/VMFloat.java
java/lang/VMSystem.java
java/lang/ExceptionHelper.java java/lang/ExceptionHelper.java
java/lang/ObjectHelper.java java/lang/ObjectHelper.java
java/lang/StringHelper.java java/lang/StringHelper.java
@ -294,6 +295,8 @@ sun/misc/Ref.java
../../classpath/gnu/java/security/Engine.java ../../classpath/gnu/java/security/Engine.java
../../classpath/gnu/java/security/OID.java ../../classpath/gnu/java/security/OID.java
../../classpath/gnu/java/security/PolicyFile.java ../../classpath/gnu/java/security/PolicyFile.java
../../classpath/gnu/java/security/action/GetPropertyAction.java
../../classpath/gnu/java/security/action/SetAccessibleAction.java
../../classpath/gnu/java/security/der/BitString.java ../../classpath/gnu/java/security/der/BitString.java
../../classpath/gnu/java/security/der/DER.java ../../classpath/gnu/java/security/der/DER.java
../../classpath/gnu/java/security/der/DEREncodingException.java ../../classpath/gnu/java/security/der/DEREncodingException.java
@ -602,6 +605,7 @@ sun/misc/Ref.java
../../classpath/java/awt/image/BufferedImage.java ../../classpath/java/awt/image/BufferedImage.java
../../classpath/java/awt/image/BufferedImageOp.java ../../classpath/java/awt/image/BufferedImageOp.java
../../classpath/java/awt/image/BufferStrategy.java ../../classpath/java/awt/image/BufferStrategy.java
../../classpath/java/awt/image/ByteLookupTable.java
../../classpath/java/awt/image/ColorModel.java ../../classpath/java/awt/image/ColorModel.java
../../classpath/java/awt/image/ComponentColorModel.java ../../classpath/java/awt/image/ComponentColorModel.java
../../classpath/java/awt/image/ComponentSampleModel.java ../../classpath/java/awt/image/ComponentSampleModel.java
@ -621,6 +625,8 @@ sun/misc/Ref.java
../../classpath/java/awt/image/ImageProducer.java ../../classpath/java/awt/image/ImageProducer.java
../../classpath/java/awt/image/ImagingOpException.java ../../classpath/java/awt/image/ImagingOpException.java
../../classpath/java/awt/image/IndexColorModel.java ../../classpath/java/awt/image/IndexColorModel.java
../../classpath/java/awt/image/Kernel.java
../../classpath/java/awt/image/LookupTable.java
../../classpath/java/awt/image/MemoryImageSource.java ../../classpath/java/awt/image/MemoryImageSource.java
../../classpath/java/awt/image/PackedColorModel.java ../../classpath/java/awt/image/PackedColorModel.java
../../classpath/java/awt/image/PixelGrabber.java ../../classpath/java/awt/image/PixelGrabber.java
@ -632,6 +638,7 @@ sun/misc/Ref.java
../../classpath/java/awt/image/ReplicateScaleFilter.java ../../classpath/java/awt/image/ReplicateScaleFilter.java
../../classpath/java/awt/image/RGBImageFilter.java ../../classpath/java/awt/image/RGBImageFilter.java
../../classpath/java/awt/image/SampleModel.java ../../classpath/java/awt/image/SampleModel.java
../../classpath/java/awt/image/ShortLookupTable.java
../../classpath/java/awt/image/SinglePixelPackedSampleModel.java ../../classpath/java/awt/image/SinglePixelPackedSampleModel.java
../../classpath/java/awt/image/TileObserver.java ../../classpath/java/awt/image/TileObserver.java
../../classpath/java/awt/image/VolatileImage.java ../../classpath/java/awt/image/VolatileImage.java
@ -687,8 +694,10 @@ sun/misc/Ref.java
../../classpath/java/beans/Beans.java ../../classpath/java/beans/Beans.java
../../classpath/java/beans/Customizer.java ../../classpath/java/beans/Customizer.java
../../classpath/java/beans/DesignMode.java ../../classpath/java/beans/DesignMode.java
../../classpath/java/beans/EventHandler.java
../../classpath/java/beans/EventSetDescriptor.java ../../classpath/java/beans/EventSetDescriptor.java
../../classpath/java/beans/ExceptionListener.java ../../classpath/java/beans/ExceptionListener.java
../../classpath/java/beans/Expression.java
../../classpath/java/beans/FeatureDescriptor.java ../../classpath/java/beans/FeatureDescriptor.java
../../classpath/java/beans/IndexedPropertyDescriptor.java ../../classpath/java/beans/IndexedPropertyDescriptor.java
../../classpath/java/beans/IntrospectionException.java ../../classpath/java/beans/IntrospectionException.java
@ -705,6 +714,7 @@ sun/misc/Ref.java
../../classpath/java/beans/PropertyEditorSupport.java ../../classpath/java/beans/PropertyEditorSupport.java
../../classpath/java/beans/PropertyVetoException.java ../../classpath/java/beans/PropertyVetoException.java
../../classpath/java/beans/SimpleBeanInfo.java ../../classpath/java/beans/SimpleBeanInfo.java
../../classpath/java/beans/Statement.java
../../classpath/java/beans/VetoableChangeListener.java ../../classpath/java/beans/VetoableChangeListener.java
../../classpath/java/beans/VetoableChangeListenerProxy.java ../../classpath/java/beans/VetoableChangeListenerProxy.java
../../classpath/java/beans/VetoableChangeSupport.java ../../classpath/java/beans/VetoableChangeSupport.java
@ -1202,8 +1212,10 @@ sun/misc/Ref.java
../../classpath/java/security/cert/PolicyQualifierInfo.java ../../classpath/java/security/cert/PolicyQualifierInfo.java
../../classpath/java/security/cert/TrustAnchor.java ../../classpath/java/security/cert/TrustAnchor.java
../../classpath/java/security/cert/X509Certificate.java ../../classpath/java/security/cert/X509Certificate.java
../../classpath/java/security/cert/X509CertSelector.java
../../classpath/java/security/cert/X509CRL.java ../../classpath/java/security/cert/X509CRL.java
../../classpath/java/security/cert/X509CRLEntry.java ../../classpath/java/security/cert/X509CRLEntry.java
../../classpath/java/security/cert/X509CRLSelector.java
../../classpath/java/security/cert/X509Extension.java ../../classpath/java/security/cert/X509Extension.java
../../classpath/java/security/interfaces/DSAKey.java ../../classpath/java/security/interfaces/DSAKey.java
../../classpath/java/security/interfaces/DSAKeyPairGenerator.java ../../classpath/java/security/interfaces/DSAKeyPairGenerator.java
@ -1429,6 +1441,46 @@ sun/misc/Ref.java
../../classpath/javax/accessibility/AccessibleTableModelChange.java ../../classpath/javax/accessibility/AccessibleTableModelChange.java
../../classpath/javax/accessibility/AccessibleText.java ../../classpath/javax/accessibility/AccessibleText.java
../../classpath/javax/accessibility/AccessibleValue.java ../../classpath/javax/accessibility/AccessibleValue.java
../../classpath/javax/crypto/BadPaddingException.java
../../classpath/javax/crypto/Cipher.java
../../classpath/javax/crypto/CipherInputStream.java
../../classpath/javax/crypto/CipherOutputStream.java
../../classpath/javax/crypto/CipherSpi.java
../../classpath/javax/crypto/EncryptedPrivateKeyInfo.java
../../classpath/javax/crypto/ExemptionMechanism.java
../../classpath/javax/crypto/ExemptionMechanismException.java
../../classpath/javax/crypto/ExemptionMechanismSpi.java
../../classpath/javax/crypto/IllegalBlockSizeException.java
../../classpath/javax/crypto/KeyAgreement.java
../../classpath/javax/crypto/KeyAgreementSpi.java
../../classpath/javax/crypto/KeyGenerator.java
../../classpath/javax/crypto/KeyGeneratorSpi.java
../../classpath/javax/crypto/Mac.java
../../classpath/javax/crypto/MacSpi.java
../../classpath/javax/crypto/NoSuchPaddingException.java
../../classpath/javax/crypto/NullCipher.java
../../classpath/javax/crypto/NullCipherImpl.java
../../classpath/javax/crypto/SealedObject.java
../../classpath/javax/crypto/SecretKey.java
../../classpath/javax/crypto/SecretKeyFactory.java
../../classpath/javax/crypto/SecretKeyFactorySpi.java
../../classpath/javax/crypto/ShortBufferException.java
../../classpath/javax/crypto/interfaces/DHKey.java
../../classpath/javax/crypto/interfaces/DHPrivateKey.java
../../classpath/javax/crypto/interfaces/DHPublicKey.java
../../classpath/javax/crypto/interfaces/PBEKey.java
../../classpath/javax/crypto/spec/DESedeKeySpec.java
../../classpath/javax/crypto/spec/DESKeySpec.java
../../classpath/javax/crypto/spec/DHGenParameterSpec.java
../../classpath/javax/crypto/spec/DHParameterSpec.java
../../classpath/javax/crypto/spec/DHPrivateKeySpec.java
../../classpath/javax/crypto/spec/DHPublicKeySpec.java
../../classpath/javax/crypto/spec/IvParameterSpec.java
../../classpath/javax/crypto/spec/PBEKeySpec.java
../../classpath/javax/crypto/spec/PBEParameterSpec.java
../../classpath/javax/crypto/spec/RC2ParameterSpec.java
../../classpath/javax/crypto/spec/RC5ParameterSpec.java
../../classpath/javax/crypto/spec/SecretKeySpec.java
../../classpath/javax/imageio/IIOException.java ../../classpath/javax/imageio/IIOException.java
../../classpath/javax/imageio/ImageReader.java ../../classpath/javax/imageio/ImageReader.java
../../classpath/javax/imageio/ImageTranscoder.java ../../classpath/javax/imageio/ImageTranscoder.java
@ -1536,6 +1588,40 @@ sun/misc/Ref.java
../../classpath/javax/naming/spi/Resolver.java ../../classpath/javax/naming/spi/Resolver.java
../../classpath/javax/naming/spi/ResolveResult.java ../../classpath/javax/naming/spi/ResolveResult.java
../../classpath/javax/naming/spi/StateFactory.java ../../classpath/javax/naming/spi/StateFactory.java
../../classpath/javax/net/ServerSocketFactory.java
../../classpath/javax/net/SocketFactory.java
../../classpath/javax/net/VanillaServerSocketFactory.java
../../classpath/javax/net/VanillaSocketFactory.java
../../classpath/javax/net/ssl/HandshakeCompletedEvent.java
../../classpath/javax/net/ssl/HandshakeCompletedListener.java
../../classpath/javax/net/ssl/HostnameVerifier.java
../../classpath/javax/net/ssl/HttpsURLConnection.java
../../classpath/javax/net/ssl/KeyManager.java
../../classpath/javax/net/ssl/KeyManagerFactory.java
../../classpath/javax/net/ssl/KeyManagerFactorySpi.java
../../classpath/javax/net/ssl/ManagerFactoryParameters.java
../../classpath/javax/net/ssl/SSLContext.java
../../classpath/javax/net/ssl/SSLContextSpi.java
../../classpath/javax/net/ssl/SSLException.java
../../classpath/javax/net/ssl/SSLHandshakeException.java
../../classpath/javax/net/ssl/SSLKeyException.java
../../classpath/javax/net/ssl/SSLPeerUnverifiedException.java
../../classpath/javax/net/ssl/SSLPermission.java
../../classpath/javax/net/ssl/SSLProtocolException.java
../../classpath/javax/net/ssl/SSLServerSocket.java
../../classpath/javax/net/ssl/SSLServerSocketFactory.java
../../classpath/javax/net/ssl/SSLSession.java
../../classpath/javax/net/ssl/SSLSessionBindingEvent.java
../../classpath/javax/net/ssl/SSLSessionBindingListener.java
../../classpath/javax/net/ssl/SSLSessionContext.java
../../classpath/javax/net/ssl/SSLSocket.java
../../classpath/javax/net/ssl/SSLSocketFactory.java
../../classpath/javax/net/ssl/TrivialHostnameVerifier.java
../../classpath/javax/net/ssl/TrustManager.java
../../classpath/javax/net/ssl/TrustManagerFactory.java
../../classpath/javax/net/ssl/TrustManagerFactorySpi.java
../../classpath/javax/net/ssl/X509KeyManager.java
../../classpath/javax/net/ssl/X509TrustManager.java
../../classpath/javax/print/AttributeException.java ../../classpath/javax/print/AttributeException.java
../../classpath/javax/print/CancelablePrintJob.java ../../classpath/javax/print/CancelablePrintJob.java
../../classpath/javax/print/Doc.java ../../classpath/javax/print/Doc.java
@ -1661,7 +1747,53 @@ sun/misc/Ref.java
../../classpath/javax/rmi/CORBA/Util.java ../../classpath/javax/rmi/CORBA/Util.java
../../classpath/javax/rmi/CORBA/UtilDelegate.java ../../classpath/javax/rmi/CORBA/UtilDelegate.java
../../classpath/javax/rmi/CORBA/ValueHandler.java ../../classpath/javax/rmi/CORBA/ValueHandler.java
../../classpath/javax/security/auth/AuthPermission.java
../../classpath/javax/security/auth/Destroyable.java
../../classpath/javax/security/auth/DestroyFailedException.java
../../classpath/javax/security/auth/Policy.java
../../classpath/javax/security/auth/PrivateCredentialPermission.java
../../classpath/javax/security/auth/Refreshable.java
../../classpath/javax/security/auth/RefreshFailedException.java
../../classpath/javax/security/auth/Subject.java
../../classpath/javax/security/auth/SubjectDomainCombiner.java
../../classpath/javax/security/auth/callback/Callback.java
../../classpath/javax/security/auth/callback/CallbackHandler.java
../../classpath/javax/security/auth/callback/ChoiceCallback.java
../../classpath/javax/security/auth/callback/ConfirmationCallback.java
../../classpath/javax/security/auth/callback/LanguageCallback.java
../../classpath/javax/security/auth/callback/NameCallback.java
../../classpath/javax/security/auth/callback/PasswordCallback.java
../../classpath/javax/security/auth/callback/TextInputCallback.java
../../classpath/javax/security/auth/callback/TextOutputCallback.java
../../classpath/javax/security/auth/callback/UnsupportedCallbackException.java
../../classpath/javax/security/auth/login/AccountExpiredException.java
../../classpath/javax/security/auth/login/AppConfigurationEntry.java
../../classpath/javax/security/auth/login/Configuration.java
../../classpath/javax/security/auth/login/CredentialExpiredException.java
../../classpath/javax/security/auth/login/FailedLoginException.java
../../classpath/javax/security/auth/login/LoginContext.java
../../classpath/javax/security/auth/login/LoginException.java
../../classpath/javax/security/auth/login/NullConfiguration.java
../../classpath/javax/security/auth/x500/X500Principal.java ../../classpath/javax/security/auth/x500/X500Principal.java
../../classpath/javax/security/auth/x500/X500PrivateCredential.java
../../classpath/javax/security/cert/Certificate.java
../../classpath/javax/security/cert/CertificateEncodingException.java
../../classpath/javax/security/cert/CertificateException.java
../../classpath/javax/security/cert/CertificateExpiredException.java
../../classpath/javax/security/cert/CertificateNotYetValidException.java
../../classpath/javax/security/cert/CertificateParsingException.java
../../classpath/javax/security/cert/X509CertBridge.java
../../classpath/javax/security/cert/X509Certificate.java
../../classpath/javax/security/sasl/AuthenticationException.java
../../classpath/javax/security/sasl/AuthorizeCallback.java
../../classpath/javax/security/sasl/RealmCallback.java
../../classpath/javax/security/sasl/RealmChoiceCallback.java
../../classpath/javax/security/sasl/Sasl.java
../../classpath/javax/security/sasl/SaslClient.java
../../classpath/javax/security/sasl/SaslClientFactory.java
../../classpath/javax/security/sasl/SaslException.java
../../classpath/javax/security/sasl/SaslServer.java
../../classpath/javax/security/sasl/SaslServerFactory.java
../../classpath/javax/sql/ConnectionEvent.java ../../classpath/javax/sql/ConnectionEvent.java
../../classpath/javax/sql/ConnectionEventListener.java ../../classpath/javax/sql/ConnectionEventListener.java
../../classpath/javax/sql/ConnectionPoolDataSource.java ../../classpath/javax/sql/ConnectionPoolDataSource.java
@ -1681,6 +1813,7 @@ sun/misc/Ref.java
../../classpath/javax/swing/AbstractCellEditor.java ../../classpath/javax/swing/AbstractCellEditor.java
../../classpath/javax/swing/AbstractListModel.java ../../classpath/javax/swing/AbstractListModel.java
../../classpath/javax/swing/AbstractSet.java ../../classpath/javax/swing/AbstractSet.java
../../classpath/javax/swing/AbstractSpinnerModel.java
../../classpath/javax/swing/Action.java ../../classpath/javax/swing/Action.java
../../classpath/javax/swing/ActionMap.java ../../classpath/javax/swing/ActionMap.java
../../classpath/javax/swing/BorderFactory.java ../../classpath/javax/swing/BorderFactory.java
@ -1745,6 +1878,7 @@ sun/misc/Ref.java
../../classpath/javax/swing/JScrollPane.java ../../classpath/javax/swing/JScrollPane.java
../../classpath/javax/swing/JSeparator.java ../../classpath/javax/swing/JSeparator.java
../../classpath/javax/swing/JSlider.java ../../classpath/javax/swing/JSlider.java
../../classpath/javax/swing/JSpinner.java
../../classpath/javax/swing/JSplitPane.java ../../classpath/javax/swing/JSplitPane.java
../../classpath/javax/swing/JTabbedPane.java ../../classpath/javax/swing/JTabbedPane.java
../../classpath/javax/swing/JTable.java ../../classpath/javax/swing/JTable.java
@ -1779,7 +1913,11 @@ sun/misc/Ref.java
../../classpath/javax/swing/SingleSelectionModel.java ../../classpath/javax/swing/SingleSelectionModel.java
../../classpath/javax/swing/SizeRequirements.java ../../classpath/javax/swing/SizeRequirements.java
../../classpath/javax/swing/SizeSequence.java ../../classpath/javax/swing/SizeSequence.java
../../classpath/javax/swing/SpinnerListModel.java
../../classpath/javax/swing/SpinnerModel.java ../../classpath/javax/swing/SpinnerModel.java
../../classpath/javax/swing/SpinnerNumberModel.java
../../classpath/javax/swing/Spring.java
../../classpath/javax/swing/SpringLayout.java
../../classpath/javax/swing/SwingConstants.java ../../classpath/javax/swing/SwingConstants.java
../../classpath/javax/swing/SwingUtilities.java ../../classpath/javax/swing/SwingUtilities.java
../../classpath/javax/swing/Timer.java ../../classpath/javax/swing/Timer.java
@ -1920,12 +2058,16 @@ sun/misc/Ref.java
../../classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java ../../classpath/javax/swing/plaf/basic/BasicScrollPaneUI.java
../../classpath/javax/swing/plaf/basic/BasicSeparatorUI.java ../../classpath/javax/swing/plaf/basic/BasicSeparatorUI.java
../../classpath/javax/swing/plaf/basic/BasicSliderUI.java ../../classpath/javax/swing/plaf/basic/BasicSliderUI.java
../../classpath/javax/swing/plaf/basic/BasicSpinnerUI.java
../../classpath/javax/swing/plaf/basic/BasicSplitPaneDivider.java ../../classpath/javax/swing/plaf/basic/BasicSplitPaneDivider.java
../../classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java ../../classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java
../../classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java ../../classpath/javax/swing/plaf/basic/BasicTabbedPaneUI.java
../../classpath/javax/swing/plaf/basic/BasicTextFieldUI.java
../../classpath/javax/swing/plaf/basic/BasicTextUI.java ../../classpath/javax/swing/plaf/basic/BasicTextUI.java
../../classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java ../../classpath/javax/swing/plaf/basic/BasicToggleButtonUI.java
../../classpath/javax/swing/plaf/basic/BasicToolBarSeparatorUI.java
../../classpath/javax/swing/plaf/basic/BasicToolBarUI.java ../../classpath/javax/swing/plaf/basic/BasicToolBarUI.java
../../classpath/javax/swing/plaf/basic/BasicToolTipUI.java
../../classpath/javax/swing/plaf/basic/BasicTreeUI.java ../../classpath/javax/swing/plaf/basic/BasicTreeUI.java
../../classpath/javax/swing/plaf/basic/BasicViewportUI.java ../../classpath/javax/swing/plaf/basic/BasicViewportUI.java
../../classpath/javax/swing/plaf/metal/MetalLookAndFeel.java ../../classpath/javax/swing/plaf/metal/MetalLookAndFeel.java
@ -1943,26 +2085,31 @@ sun/misc/Ref.java
../../classpath/javax/swing/text/AttributeSet.java ../../classpath/javax/swing/text/AttributeSet.java
../../classpath/javax/swing/text/BadLocationException.java ../../classpath/javax/swing/text/BadLocationException.java
../../classpath/javax/swing/text/Caret.java ../../classpath/javax/swing/text/Caret.java
../../classpath/javax/swing/text/CharacterIterator.java
../../classpath/javax/swing/text/ComponentView.java ../../classpath/javax/swing/text/ComponentView.java
../../classpath/javax/swing/text/DefaultCaret.java ../../classpath/javax/swing/text/DefaultCaret.java
../../classpath/javax/swing/text/DefaultEditorKit.java ../../classpath/javax/swing/text/DefaultEditorKit.java
../../classpath/javax/swing/text/DefaultHighlighter.java
../../classpath/javax/swing/text/Document.java ../../classpath/javax/swing/text/Document.java
../../classpath/javax/swing/text/DocumentFilter.java ../../classpath/javax/swing/text/DocumentFilter.java
../../classpath/javax/swing/text/EditorKit.java ../../classpath/javax/swing/text/EditorKit.java
../../classpath/javax/swing/text/Element.java ../../classpath/javax/swing/text/Element.java
../../classpath/javax/swing/text/FieldView.java
../../classpath/javax/swing/text/GapContent.java ../../classpath/javax/swing/text/GapContent.java
../../classpath/javax/swing/text/Highlighter.java
../../classpath/javax/swing/text/JTextComponent.java ../../classpath/javax/swing/text/JTextComponent.java
../../classpath/javax/swing/text/Keymap.java ../../classpath/javax/swing/text/Keymap.java
../../classpath/javax/swing/text/LayeredHighlighter.java
../../classpath/javax/swing/text/MutableAttributeSet.java ../../classpath/javax/swing/text/MutableAttributeSet.java
../../classpath/javax/swing/text/NavigationFilter.java ../../classpath/javax/swing/text/NavigationFilter.java
../../classpath/javax/swing/text/PlainDocument.java ../../classpath/javax/swing/text/PlainDocument.java
../../classpath/javax/swing/text/PlainEditorKit.java ../../classpath/javax/swing/text/PlainView.java
../../classpath/javax/swing/text/Position.java ../../classpath/javax/swing/text/Position.java
../../classpath/javax/swing/text/Segment.java ../../classpath/javax/swing/text/Segment.java
../../classpath/javax/swing/text/Style.java ../../classpath/javax/swing/text/Style.java
../../classpath/javax/swing/text/StyledDocument.java ../../classpath/javax/swing/text/StyledDocument.java
../../classpath/javax/swing/text/StyledEditorKit.java ../../classpath/javax/swing/text/StyledEditorKit.java
../../classpath/javax/swing/text/TabableView.java
../../classpath/javax/swing/text/TabExpander.java
../../classpath/javax/swing/text/TextAction.java ../../classpath/javax/swing/text/TextAction.java
../../classpath/javax/swing/text/View.java ../../classpath/javax/swing/text/View.java
../../classpath/javax/swing/text/ViewFactory.java ../../classpath/javax/swing/text/ViewFactory.java
@ -2011,11 +2158,19 @@ sun/misc/Ref.java
../../classpath/javax/transaction/xa/XAException.java ../../classpath/javax/transaction/xa/XAException.java
../../classpath/javax/transaction/xa/XAResource.java ../../classpath/javax/transaction/xa/XAResource.java
../../classpath/javax/transaction/xa/Xid.java ../../classpath/javax/transaction/xa/Xid.java
../../classpath/org/ietf/jgss/ChannelBinding.java
../../classpath/org/ietf/jgss/GSSContext.java
../../classpath/org/ietf/jgss/GSSCredential.java
../../classpath/org/ietf/jgss/GSSException.java
../../classpath/org/ietf/jgss/GSSManager.java
../../classpath/org/ietf/jgss/GSSName.java
../../classpath/org/ietf/jgss/MessageProp.java
../../classpath/org/ietf/jgss/Oid.java
../../classpath/vm/reference/gnu/java/nio/VMSelector.java
../../classpath/vm/reference/java/io/VMObjectStreamClass.java ../../classpath/vm/reference/java/io/VMObjectStreamClass.java
../../classpath/vm/reference/java/lang/VMObject.java ../../classpath/vm/reference/java/lang/VMObject.java
../../classpath/vm/reference/java/lang/VMSecurityManager.java ../../classpath/vm/reference/java/lang/VMSecurityManager.java
../../classpath/vm/reference/java/lang/VMString.java ../../classpath/vm/reference/java/lang/VMString.java
../../classpath/vm/reference/java/lang/VMSystem.java
../../classpath/vm/reference/java/lang/VMThrowable.java ../../classpath/vm/reference/java/lang/VMThrowable.java
../../classpath/vm/reference/java/security/VMAccessController.java ../../classpath/vm/reference/java/security/VMAccessController.java
../../classpath/vm/reference/gnu/java/nio/VMPipe.java ../../classpath/vm/reference/gnu/java/nio/VMPipe.java

Просмотреть файл

@ -93,7 +93,7 @@ final class VMRuntime
static long totalMemory() static long totalMemory()
{ {
// NOTE this really is a bogus number, but we have to return something // NOTE this really is a bogus number, but we have to return something
return cli.System.GC.GetTotalMemory(false); return cli.System.GC.GetTotalMemory(false) + freeMemory();
} }
/** /**

Просмотреть файл

@ -867,6 +867,8 @@
<stloc name="x" class="java.lang.ThreadDeath" /> <stloc name="x" class="java.lang.ThreadDeath" />
<exceptionBlock> <exceptionBlock>
<try> <try>
<!-- TODO instead of catching the ThreadStateException, we should check the ThreadState
before calling ResetAbort -->
<call type="System.Threading.Thread, mscorlib" name="ResetAbort" sig="()V" /> <call type="System.Threading.Thread, mscorlib" name="ResetAbort" sig="()V" />
</try> </try>
<catch type="System.Threading.ThreadStateException, mscorlib"> <catch type="System.Threading.ThreadStateException, mscorlib">

Просмотреть файл

@ -2,10 +2,7 @@
<project name="ikvm" default="all"> <project name="ikvm" default="all">
<target name="all"> <target name="all">
<nant buildfile="runtime/runtime.build" /> <nant buildfile="runtime/runtime.build" />
<if propertytrue="nant.platform.win32"> <nant buildfile="native/native.build" />
<nant buildfile="jni/clr-win32/clr-win32.build" />
</if>
<nant buildfile="jni/mono/mono.build" />
<nant buildfile="ikvmc/ikvmc.build" /> <nant buildfile="ikvmc/ikvmc.build" />
<nant buildfile="classpath/classpath.build" /> <nant buildfile="classpath/classpath.build" />
<nant buildfile="ikvm/ikvm.build" /> <nant buildfile="ikvm/ikvm.build" />
@ -20,8 +17,8 @@
<includes name="bin/IKVM.AWT.WinForms.dll" /> <includes name="bin/IKVM.AWT.WinForms.dll" />
<includes name="bin/IKVM.Runtime.dll" /> <includes name="bin/IKVM.Runtime.dll" />
<includes name="bin/IKVM.GNU.Classpath.dll" /> <includes name="bin/IKVM.GNU.Classpath.dll" />
<includes name="bin/IKVM.JNI.CLR-Win32.dll" /> <includes name="bin/ikvm-native.dll" />
<includes name="bin/IKVM.JNI.Mono.dll" /> <includes name="bin/libikvm-native.so" />
<includes name="bin/ikvm.exe" /> <includes name="bin/ikvm.exe" />
<includes name="bin/ikvmc.exe" /> <includes name="bin/ikvmc.exe" />
<includes name="bin/ikvmstub.exe" /> <includes name="bin/ikvmstub.exe" />

Просмотреть файл

@ -3,10 +3,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IKVM.Runtime", "runtime\IKV
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IKVM.JNI.CLR-Win32", "jni\clr-win32\IKVM.JNI.CLR-Win32.vcproj", "{4D400F9D-68A1-4066-95F6-85AF0E58B710}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ikvm", "ikvm\ikvm.csproj", "{4FBAFF23-1E48-4977-8C50-30F87E70A8B5}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ikvm", "ikvm\ikvm.csproj", "{4FBAFF23-1E48-4977-8C50-30F87E70A8B5}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
EndProjectSection EndProjectSection
@ -23,6 +19,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IKVM.AWT.WinForms", "awt\IK
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ikvm-native", "native\native.vcproj", "{14EC8F2A-90C6-4CFC-AD26-04C9A3392B8E}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfiguration) = preSolution GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug Debug = Debug
@ -33,10 +33,6 @@ Global
{F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}.Debug.Build.0 = Debug|.NET {F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}.Debug.Build.0 = Debug|.NET
{F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}.Release.ActiveCfg = Release|.NET {F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}.Release.ActiveCfg = Release|.NET
{F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}.Release.Build.0 = Release|.NET {F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}.Release.Build.0 = Release|.NET
{4D400F9D-68A1-4066-95F6-85AF0E58B710}.Debug.ActiveCfg = Debug|Win32
{4D400F9D-68A1-4066-95F6-85AF0E58B710}.Debug.Build.0 = Debug|Win32
{4D400F9D-68A1-4066-95F6-85AF0E58B710}.Release.ActiveCfg = Release|Win32
{4D400F9D-68A1-4066-95F6-85AF0E58B710}.Release.Build.0 = Release|Win32
{4FBAFF23-1E48-4977-8C50-30F87E70A8B5}.Debug.ActiveCfg = Debug|.NET {4FBAFF23-1E48-4977-8C50-30F87E70A8B5}.Debug.ActiveCfg = Debug|.NET
{4FBAFF23-1E48-4977-8C50-30F87E70A8B5}.Debug.Build.0 = Debug|.NET {4FBAFF23-1E48-4977-8C50-30F87E70A8B5}.Debug.Build.0 = Debug|.NET
{4FBAFF23-1E48-4977-8C50-30F87E70A8B5}.Release.ActiveCfg = Release|.NET {4FBAFF23-1E48-4977-8C50-30F87E70A8B5}.Release.ActiveCfg = Release|.NET
@ -53,6 +49,10 @@ Global
{E00A0FA2-1FD7-4DD9-8C06-7202CE366102}.Debug.Build.0 = Debug|.NET {E00A0FA2-1FD7-4DD9-8C06-7202CE366102}.Debug.Build.0 = Debug|.NET
{E00A0FA2-1FD7-4DD9-8C06-7202CE366102}.Release.ActiveCfg = Release|.NET {E00A0FA2-1FD7-4DD9-8C06-7202CE366102}.Release.ActiveCfg = Release|.NET
{E00A0FA2-1FD7-4DD9-8C06-7202CE366102}.Release.Build.0 = Release|.NET {E00A0FA2-1FD7-4DD9-8C06-7202CE366102}.Release.Build.0 = Release|.NET
{14EC8F2A-90C6-4CFC-AD26-04C9A3392B8E}.Debug.ActiveCfg = Debug|Win32
{14EC8F2A-90C6-4CFC-AD26-04C9A3392B8E}.Debug.Build.0 = Debug|Win32
{14EC8F2A-90C6-4CFC-AD26-04C9A3392B8E}.Release.ActiveCfg = Release|Win32
{14EC8F2A-90C6-4CFC-AD26-04C9A3392B8E}.Release.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection EndGlobalSection

Просмотреть файл

@ -1,81 +0,0 @@
/*
Copyright (C) 2002 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
#include "stdafx.h"
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("")];
[assembly:AssemblyCopyrightAttribute("")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("0.9.*")];
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project directory.
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly:AssemblyDelaySignAttribute(false)];
//[assembly: AssemblyKeyFile("c:\\ikvm-key\\ikvm.snk")];
[assembly:AssemblyKeyNameAttribute("")];

Просмотреть файл

@ -1,5 +0,0 @@
// stdafx.cpp : source file that includes just the standard includes
// jni.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

Просмотреть файл

@ -1,9 +0,0 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#using <mscorlib.dll>
#include <windows.h>

Просмотреть файл

@ -1,16 +0,0 @@
<?xml version="1.0"?>
<project name="IKVM.JNI.CLR-Win32" default="IKVM.JNI.CLR-Win32">
<target name="IKVM.JNI.CLR-Win32">
<mkdir dir="release"/>
<cl outputdir="Release" pchfile="stdafx.h" options="/O2 /D WIN32 /D NDEBUG /D _WINDLL /D _MBCS /FD /EHac /GS /Zc:wchar_t /Zc:forScope /W3 /nologo /c /Zi /clr /TP /FU ..\..\bin\IKVM.Runtime.dll">
<sources>
<includes name="*.cpp"/>
</sources>
</cl>
<link output="../../bin/IKVM.JNI.CLR-Win32.dll" options="/DLL /FIXED:No">
<sources>
<includes name="Release/*.obj"/>
</sources>
</link>
</target>
</project>

Просмотреть файл

@ -1,269 +0,0 @@
/*
Copyright (C) 2002, 2004 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
#include "stdafx.h"
#include <malloc.h>
#include "jnienv.h"
#include "jni.h"
#pragma managed
#include <stdio.h>
using namespace System;
using namespace System::Collections;
using namespace System::Runtime::InteropServices;
using namespace System::Reflection;
typedef JNIEXPORT jint (JNICALL *PJNI_ONLOAD)(JavaVM* vm, void* reserved);
int JNI::LoadNativeLibrary(String* name)
{
HMODULE hMod = LoadLibrary(name);
if(!hMod)
{
return 0;
}
//void* pOnLoad = GetProcAddress(hMod, S"_JNI_OnLoad@8");
//if(pOnLoad)
//{
// JavaVM* pVM;
// ((JNIEnv*)0)->JNIEnv::GetJavaVM(&pVM);
// LocalRefStruct loc;
// loc.Enter();
// jint version = ((PJNI_ONLOAD)pOnLoad)(pVM, 0);
// try
// {
// loc.Leave();
// }
// catch(...)
// {
// // If the JNI_OnLoad procedure threw an exception, we have to unload the library
// FreeLibrary(hMod);
// throw;
// }
// if(version != JNI_VERSION_1_1 && version != JNI_VERSION_1_2 && version != JNI_VERSION_1_4)
// {
// // NOTE we don't call JNI_OnUnload when the version doesn't match!
// FreeLibrary(hMod);
// throw VM::UnsatisfiedLinkError(String::Format(S"Unsupported JNI version 0x{0:X} required by {1}", __box(version), name));
// }
//}
libs->Add(__box((int)hMod));
return 1;
}
Type* JNI::GetLocalRefStructType()
{
return 0;
//return __typeof(LocalRefStruct);
}
MethodInfo* JNI::GetJniFuncPtrMethod()
{
return __typeof(JNI)->GetMethod("GetJniFuncPtr");
}
IntPtr JNI::GetJniFuncPtr(String* method, String* sig, String* clazz)
{
System::Text::StringBuilder* mangledSig = new System::Text::StringBuilder();
int sp = 0;
for(int i = 1; sig->Chars[i] != ')'; i++)
{
switch(sig->Chars[i])
{
case '[':
mangledSig->Append(S"_3");
sp += 4;
while(sig->Chars[++i] == '[')
{
mangledSig->Append(S"_3");
}
mangledSig->Append(sig->Chars[i]);
if(sig->Chars[i] == 'L')
{
while(sig->Chars[++i] != ';')
{
if(sig->Chars[i] == '/')
{
mangledSig->Append(S"_");
}
else if(sig->Chars[i] == '_')
{
mangledSig->Append(S"_1");
}
else
{
mangledSig->Append(sig->Chars[i]);
}
}
mangledSig->Append(S"_2");
}
break;
case 'L':
sp += 4;
mangledSig->Append(S"L");
while(sig->Chars[++i] != ';')
{
if(sig->Chars[i] == '/')
{
mangledSig->Append(S"_");
}
else if(sig->Chars[i] == '_')
{
mangledSig->Append(S"_1");
}
else
{
mangledSig->Append(sig->Chars[i]);
}
}
mangledSig->Append(S"_2");
break;
case 'J':
case 'D':
mangledSig->Append(sig->Chars[i]);
sp += 8;
break;
case 'F':
case 'I':
case 'C':
case 'Z':
case 'S':
case 'B':
mangledSig->Append(sig->Chars[i]);
sp += 4;
break;
default:
DebugBreak();
throw new NotImplementedException();
}
}
void* func = 0;
// TODO implement this correctly
String* methodName = String::Format(S"_Java_{0}_{1}@{2}", clazz->Replace(S"_", S"_1")->Replace('/', '_'), method->Replace(S"_", S"_1"), __box(sp + 8));
for(int i = 0; i < libs->Count; i++)
{
HMODULE hMod = (HMODULE)__unbox<int>(libs->Item[i]);
func = GetProcAddress(hMod, methodName);
if(func)
{
return (IntPtr)func;
}
}
methodName = String::Concat(String::Format(S"_Java_{0}_{1}__{2}@", clazz->Replace(S"_", S"_1")->Replace('/', '_'), method->Replace(S"_", S"_1"), mangledSig), __box(sp + 8));
for(int i = 0; i < libs->Count; i++)
{
HMODULE hMod = (HMODULE)__unbox<int>(libs->Item[i]);
func = GetProcAddress(hMod, methodName);
if(func)
{
return (IntPtr)func;
}
}
throw VM::UnsatisfiedLinkError(methodName);
}
//// If we put the ThreadStatic in LocalRefStruct we get an ExecutionEngineException (?!)
//__gc class TlsHack
//{
//public:
// [ThreadStatic]
// static JNIEnv* pJNIEnv;
//};
//
//JNIEnv* LocalRefStruct::GetEnv()
//{
// return TlsHack::pJNIEnv;
//}
//
//IntPtr LocalRefStruct::Enter()
//{
// pJNIEnv = TlsHack::pJNIEnv;
// if(!pJNIEnv)
// {
// // TODO we should create a managed helper object that deletes JNIEnv when the thread dies
// pJNIEnv = TlsHack::pJNIEnv = new JNIEnv();
// pJNIEnv->pendingException = 0;
// pJNIEnv->localRefSlot = 0;
// localRefs = pJNIEnv->localRefs = new LocalRefListEntry __gc[32];
// }
// else
// {
// pPrevLocalRefCache = pJNIEnv->pActiveLocalRefCache;
// localRefs = pJNIEnv->localRefs;
// }
//
// pJNIEnv->localRefSlot++;
// if(pJNIEnv->localRefSlot >= 32)
// {
// // TODO instead of bailing out, we should grow the array
// VM::FatalError("JNI nesting too deep");
// }
//
// // NOTE since this __value type can (should) only be allocated on the stack,
// // it is "safe" to store the this pointer in a __nogc*, but the compiler
// // doesn't know this, so we have to use a __pin* to bypass its checks.
// LocalRefStruct __pin* pPinHack = this;
// pJNIEnv->pActiveLocalRefCache = pPinHack;
// localRefs[pJNIEnv->localRefSlot].static_list = &pPinHack->fastlocalrefs.loc1;
// return (IntPtr)pJNIEnv;
//}
//
//void LocalRefStruct::Leave()
//{
// Object* x = pJNIEnv->UnwrapRef(pJNIEnv->pendingException);
// pJNIEnv->pendingException = 0;
// pJNIEnv->pActiveLocalRefCache = pPrevLocalRefCache;
// localRefs[pJNIEnv->localRefSlot].dynamic_list = 0;
// // TODO figure out if it is legal to Leave a JNI method while PushLocalFrame is active (i.e. without the corresponding PopLocalFrame)
// pJNIEnv->localRefSlot--;
// if(x)
// {
// throw x;
// }
//}
//
//IntPtr LocalRefStruct::MakeLocalRef(Object* obj)
//{
// if(obj == 0)
// {
// return 0;
// }
// int i = localRefs[pJNIEnv->localRefSlot].MakeLocalRef(obj);
// if(i >= 0)
// {
// return (pJNIEnv->localRefSlot << LOCAL_REF_SHIFT) + i;
// }
// // TODO consider allocating a new slot (if we do this, the code in
// // PushLocalFrame/PopLocalFrame (and Leave) must be fixed to take this into account)
// VM::FatalError("Too many JNI local references");
// return 0;
//}
//
//Object* LocalRefStruct::UnwrapLocalRef(IntPtr localref)
//{
// int i = (int)localref;
// return localRefs[i >> LOCAL_REF_SHIFT].UnwrapLocalRef(i & LOCAL_REF_MASK);
//}

Просмотреть файл

@ -1,196 +0,0 @@
/*
Copyright (C) 2002, 2004 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
#pragma once
using namespace System;
using namespace System::Collections;
using namespace System::Runtime::InteropServices;
using namespace System::Reflection;
class JNIEnv;
#pragma managed
template<class T> T __unbox(Object* o)
{
// HACK the MC++ compiler has a bug when unboxing, the static_cast<> is to work around that bug
return *(static_cast<T __gc*>(__try_cast<__box T*>(o)));
}
public __gc class JNI : public IJniProvider
{
static ArrayList* libs = new ArrayList();
[DllImport("kernel32")]
[System::Security::SuppressUnmanagedCodeSecurityAttribute]
static HMODULE LoadLibrary(String* lpLibFileName);
[DllImport("kernel32")]
[System::Security::SuppressUnmanagedCodeSecurityAttribute]
static void* GetProcAddress(HMODULE hMod, String* lpProcName);
public:
int LoadNativeLibrary(String* name);
Type* GetLocalRefStructType();
MethodInfo* GetJniFuncPtrMethod();
void** GetVtable()
{
JNIEnv p;
return *(void***)&p;
}
IntPtr LoadLibraryFoo(String* name)
{
return (IntPtr)(void*)LoadLibrary(name);
}
void FreeLibraryFoo(IntPtr p)
{
FreeLibrary((HMODULE)(void*)p);
}
IntPtr GetProcAddress(IntPtr library, String* name, int argcount)
{
String* n = String::Format(S"_{0}@{1}", name, __box(argcount));
return (IntPtr)GetProcAddress((HMODULE)(void*)library, n);
}
IntPtr GetJavaVM()
{
JavaVM* pvm;
((JNIEnv*)0)->JNIEnv::GetJavaVM(&pvm);
return pvm;
}
typedef JNIEXPORT jint (JNICALL *PJNI_ONLOAD)(JavaVM* vm, void* reserved);
int CallOnLoad(IntPtr pFunc, IntPtr javavm, IntPtr reserved)
{
return ((PJNI_ONLOAD)(void*)pFunc)((JavaVM*)(void*)javavm, (void*)reserved);
}
static IntPtr GetJniFuncPtr(String* name, String* sig, String* clazz);
};
public __gc class VM
{
public:
static IntPtr GetMethodCookie(Object* clazz, String* name, String* sig, bool isStatic)
{
return JniHelper::GetMethodCookie(clazz, name, sig, isStatic);
}
static String* GetMethodArgList(IntPtr cookie)
{
return JniHelper::GetMethodArgList(cookie);
}
static Object* InvokeMethod(IntPtr cookie, Object* obj, Object* args[], bool nonVirtual)
{
return JniHelper::InvokeMethod(cookie, obj, args, nonVirtual);
}
static IntPtr GetFieldCookie(Object* clazz, String* name, String* sig, bool isStatic)
{
return JniHelper::GetFieldCookie(clazz, name, sig, isStatic);
}
static Object* GetFieldValue(IntPtr cookie, Object* obj)
{
return JniHelper::GetFieldValue(cookie, obj);
}
static void SetFieldValue(IntPtr cookie, Object* obj, Object* value)
{
JniHelper::SetFieldValue(cookie, obj, value);
}
static Object* FindClass(String* javaName)
{
return JniHelper::FindClass(javaName);
}
static Exception* UnsatisfiedLinkError(String* msg)
{
return JniHelper::UnsatisfiedLinkError(msg);
}
static Object* GetObjectClass(Object* o)
{
return JniHelper::GetObjectClass(o);
}
static bool IsInstanceOf(Object* o, Object* clazz)
{
return JniHelper::IsInstanceOf(o, clazz);
}
static bool IsAssignableFrom(Object* sub, Object* sup)
{
return JniHelper::IsAssignableFrom(sub, sup);
}
static Object* GetSuperclass(Object* sub)
{
return JniHelper::GetSuperclass(sub);
}
static Object* AllocObject(Object* clazz)
{
return JniHelper::AllocObject(clazz);
}
static IntPtr MethodToCookie(Object* method)
{
return JniHelper::MethodToCookie(method);
}
static IntPtr FieldToCookie(Object* field)
{
return JniHelper::FieldToCookie(field);
}
static Object* CookieToMethod(IntPtr method)
{
return JniHelper::CookieToMethod(method);
}
static Object* CookieToField(IntPtr field)
{
return JniHelper::CookieToField(field);
}
static void FatalError(String* msg)
{
Console::Error->WriteLine(S"Fatal Error in JNI: {0}", msg);
JniHelper::FatalError(msg);
}
static Object* DefineClass(String* name, Object* loader, System::Byte array __gc[])
{
return JniHelper::DefineClass(name, loader, array);
}
static bool SetNativeMethodPointer(Object* clazz, String* name, String* signature, IntPtr methodPtr)
{
return JniHelper::SetNativeMethodPointer(clazz, name, signature, methodPtr);
}
static void ResetNativeMethodPointers(Object* clazz)
{
return JniHelper::ResetNativeMethodPointers(clazz);
}
static JNIEnv* GetEnv()
{
return (JNIEnv*)(void*)JniHelper::GetEnv();
}
static jobject MakeLocalRef(JNIEnv* pEnv, Object* obj)
{
return (jobject)(void*)JniHelper::MakeLocalRef(pEnv, obj);
}
static Object* UnwrapRef(JNIEnv* pEnv, jobject obj)
{
return JniHelper::UnwrapRef(pEnv, obj);
}
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,595 +0,0 @@
/*
Copyright (C) 2002, 2003, 2004 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
#include <vcclr.h>
using namespace System;
using namespace System::Runtime::InteropServices;
#pragma unmanaged
#define JNI_TRUE 1
#define JNI_FALSE 0
typedef struct {
char *name;
char *signature;
void *fnPtr;
} JNINativeMethod;
#define JNI_VERSION_1_1 0x00010001
#define JNI_VERSION_1_2 0x00010002
#define JNI_VERSION_1_4 0x00010004
/*
* possible return values for JNI functions.
*/
#define JNI_OK 0
#define JNI_ERR (-1)
#define JNI_EDETACHED (-2)
#define JNI_EVERSION (-3)
/*
* used in ReleaseScalarArrayElements
*/
#define JNI_COMMIT 1
#define JNI_ABORT 2
class JavaVM;
#define JNIEXPORT
#define JNICALL __stdcall
#ifndef _HELPERTYPES_
#define _HELPERTYPES_
class _jobject {};
class _jclass : public _jobject {};
class _jstring : public _jobject {};
class _jthrowable : public _jobject {};
class Array$ : public _jobject {};
class ObjectArray$ : public Array$ {};
class BooleanArray$ : public Array$ {};
class ByteArray$ : public Array$ {};
class CharArray$ : public Array$ {};
class ShortArray$ : public Array$ {};
class IntArray$ : public Array$ {};
class LongArray$ : public Array$ {};
class FloatArray$ : public Array$ {};
class DoubleArray$ : public Array$ {};
#endif //_HELPERTYPES_
typedef class _jclass* jclass;
typedef class _jobject* jobject;
typedef jobject jweak;
typedef class _jstring* jstring;
typedef class _jthrowable* jthrowable;
typedef class Array$* jarray;
typedef class ObjectArray$* jobjectArray;
typedef class BooleanArray$* jbooleanArray;
typedef class ByteArray$* jbyteArray;
typedef class CharArray$* jcharArray;
typedef class ShortArray$* jshortArray;
typedef class IntArray$* jintArray;
typedef class LongArray$* jlongArray;
typedef class FloatArray$* jfloatArray;
typedef class DoubleArray$* jdoubleArray;
typedef struct _jmethodID* jmethodID;
typedef struct _jfieldID* jfieldID;
struct _jmethodID
{
};
struct _jfieldID
{
};
/*
* JNI Types
*/
typedef unsigned char jboolean;
typedef unsigned short jchar;
typedef short jshort;
typedef float jfloat;
typedef double jdouble;
typedef long jint;
typedef __int64 jlong;
typedef signed char jbyte;
typedef jint jsize;
typedef union jvalue {
jboolean z;
jbyte b;
jchar c;
jshort s;
jint i;
jlong j;
jfloat f;
jdouble d;
jobject l;
} jvalue;
//public __value class LocalRefStruct;
#pragma managed
//[StructLayout(LayoutKind::Sequential)]
//__value struct LocalRefCache
//{
// Object* loc1;
// Object* loc2;
// Object* loc3;
// Object* loc4;
// Object* loc5;
// Object* loc6;
// Object* loc7;
// Object* loc8;
// Object* loc9;
// Object* loc10;
//};
//
//#define STATIC_LIST_SIZE 10
//#define BUCKET_SIZE (1 << LOCAL_REF_SHIFT)
//#define LOCAL_REF_SHIFT 10
//#define LOCAL_REF_MASK (BUCKET_SIZE - 1)
//
//__value struct LocalRefListEntry
//{
// Object* __nogc* static_list;
// Object* dynamic_list __gc[];
//
// int MakeLocalRef(Object* o)
// {
// Object** p = static_list;
// for(int i = 0; i < STATIC_LIST_SIZE; i++)
// {
// if(p[i] == 0)
// {
// p[i] = o;
// return i;
// }
// }
// if(!dynamic_list)
// {
// dynamic_list = new Object* __gc[32 - STATIC_LIST_SIZE];
// }
// for(int i = 0; i < dynamic_list->Length; i++)
// {
// if(dynamic_list[i] == 0)
// {
// dynamic_list[i] = o;
// return i + STATIC_LIST_SIZE;
// }
// }
// int newsize = (dynamic_list->Length + STATIC_LIST_SIZE) * 2 - STATIC_LIST_SIZE;
// if(newsize > BUCKET_SIZE)
// {
// return -1;
// }
// Object* tmp __gc[] = dynamic_list;
// dynamic_list = new Object* __gc[newsize];
// Array::Copy(tmp, 0, dynamic_list, 0, tmp->Length);
// dynamic_list[tmp->Length] = o;
// return tmp->Length + STATIC_LIST_SIZE;
// }
//
// void DeleteLocalRef(unsigned int i)
// {
// if(i < STATIC_LIST_SIZE)
// {
// static_list[i] = 0;
// }
// else
// {
// dynamic_list[i - STATIC_LIST_SIZE] = 0;
// }
// }
//
// Object* UnwrapLocalRef(unsigned int i)
// {
// if(i < STATIC_LIST_SIZE)
// {
// return static_list[i];
// }
// else
// {
// return dynamic_list[i - STATIC_LIST_SIZE];
// }
// }
//};
//
//__gc struct GlobalRefs
//{
// static System::Collections::ArrayList* globalRefs = new System::Collections::ArrayList();
//};
//
//class JNIEnv;
//
//public __value class LocalRefStruct
//{
// JNIEnv* pJNIEnv;
// LocalRefStruct __nogc* pPrevLocalRefCache;
// LocalRefCache fastlocalrefs;
// LocalRefListEntry localRefs __gc[];
//
//public:
// static JNIEnv* GetEnv();
//
// IntPtr Enter();
// void Leave();
//
// IntPtr MakeLocalRef(Object* o);
// Object* UnwrapLocalRef(IntPtr p);
//};
class JNIEnv
{
public:
jobject MakeLocalRef(System::Object* obj);
//{
// return (jobject)(void*)pActiveLocalRefCache->MakeLocalRef(obj);
//}
Object* UnwrapRef(jobject o);
//{
// int i = (int)o;
// if(i > 0)
// {
// return pActiveLocalRefCache->UnwrapLocalRef((void*)o);
// }
// if(i < 0)
// {
// return GlobalRefs::globalRefs->Item[(-i) - 1];
// }
// return 0;
//}
jmethodID FindMethodID(jclass cls, const char* name, const char* sig, bool isstatic);
Object* InvokeHelper(jobject object, jmethodID methodID, jvalue* args, bool nonVirtual);
jfieldID FindFieldID(jclass cls, const char* name, const char* sig, bool isstatic);
//int localRefSlot;
//LocalRefStruct __nogc* pActiveLocalRefCache;
//gcroot<LocalRefListEntry __gc[]> localRefs;
//jthrowable pendingException;
JNIEnv();
~JNIEnv();
virtual void JNICALL reserved0();
virtual void JNICALL reserved1();
virtual void JNICALL reserved2();
virtual void JNICALL reserved3();
virtual jint JNICALL GetVersion();
virtual jclass JNICALL DefineClass(const char *name, jobject loader, const jbyte *buf, jsize len);
virtual jclass JNICALL FindClass(const char *name);
virtual jmethodID JNICALL FromReflectedMethod(jobject method);
virtual jfieldID JNICALL FromReflectedField(jobject field);
virtual jobject JNICALL ToReflectedMethod(jclass clazz, jmethodID methodID);
virtual jclass JNICALL GetSuperclass(jclass sub);
virtual jboolean JNICALL IsAssignableFrom(jclass sub, jclass sup);
virtual jobject JNICALL ToReflectedField(jclass clazz, jfieldID fieldID);
virtual jint JNICALL Throw(jthrowable obj);
virtual jint JNICALL ThrowNew(jclass clazz, const char *msg);
virtual jthrowable JNICALL ExceptionOccurred();
virtual void JNICALL ExceptionDescribe();
virtual void JNICALL ExceptionClear();
virtual void JNICALL FatalError(const char *msg);
virtual jint JNICALL PushLocalFrame(jint capacity);
virtual jobject JNICALL PopLocalFrame(jobject result);
virtual jobject JNICALL NewGlobalRef(jobject lobj);
virtual void JNICALL DeleteGlobalRef(jobject gref);
virtual void JNICALL DeleteLocalRef(jobject obj);
virtual jboolean JNICALL IsSameObject(jobject obj1, jobject obj2);
virtual jobject JNICALL NewLocalRef(jobject ref);
virtual jint JNICALL EnsureLocalCapacity(jint capacity);
virtual jobject JNICALL AllocObject(jclass clazz);
virtual jobject JNICALL NewObject(jclass clazz, jmethodID methodID, ...);
virtual jobject JNICALL NewObjectV(jclass clazz, jmethodID methodID, va_list args);
virtual jobject JNICALL NewObjectA(jclass clazz, jmethodID methodID, jvalue *args);
virtual jclass JNICALL GetObjectClass(jobject obj);
virtual jboolean JNICALL IsInstanceOf(jobject obj, jclass clazz);
virtual jmethodID JNICALL GetMethodID(jclass clazz, const char *name, const char *sig);
virtual jobject JNICALL CallObjectMethod(jobject obj, jmethodID methodID, ...);
virtual jobject JNICALL CallObjectMethodV(jobject obj, jmethodID methodID, va_list args);
virtual jobject JNICALL CallObjectMethodA(jobject obj, jmethodID methodID, jvalue * args);
virtual jboolean JNICALL CallBooleanMethod(jobject obj, jmethodID methodID, ...);
virtual jboolean JNICALL CallBooleanMethodV(jobject obj, jmethodID methodID, va_list args);
virtual jboolean JNICALL CallBooleanMethodA(jobject obj, jmethodID methodID, jvalue * args);
virtual jbyte JNICALL CallByteMethod(jobject obj, jmethodID methodID, ...);
virtual jbyte JNICALL CallByteMethodV(jobject obj, jmethodID methodID, va_list args);
virtual jbyte JNICALL CallByteMethodA(jobject obj, jmethodID methodID, jvalue *args);
virtual jchar JNICALL CallCharMethod(jobject obj, jmethodID methodID, ...);
virtual jchar JNICALL CallCharMethodV(jobject obj, jmethodID methodID, va_list args);
virtual jchar JNICALL CallCharMethodA(jobject obj, jmethodID methodID, jvalue *args);
virtual jshort JNICALL CallShortMethod(jobject obj, jmethodID methodID, ...);
virtual jshort JNICALL CallShortMethodV(jobject obj, jmethodID methodID, va_list args);
virtual jshort JNICALL CallShortMethodA(jobject obj, jmethodID methodID, jvalue *args);
virtual jint JNICALL CallIntMethod(jobject obj, jmethodID methodID, ...);
virtual jint JNICALL CallIntMethodV(jobject obj, jmethodID methodID, va_list args);
virtual jint JNICALL CallIntMethodA(jobject obj, jmethodID methodID, jvalue *args);
virtual jlong JNICALL CallLongMethod(jobject obj, jmethodID methodID, ...);
virtual jlong JNICALL CallLongMethodV(jobject obj, jmethodID methodID, va_list args);
virtual jlong JNICALL CallLongMethodA(jobject obj, jmethodID methodID, jvalue *args);
virtual jfloat JNICALL CallFloatMethod(jobject obj, jmethodID methodID, ...);
virtual jfloat JNICALL CallFloatMethodV(jobject obj, jmethodID methodID, va_list args);
virtual jfloat JNICALL CallFloatMethodA(jobject obj, jmethodID methodID, jvalue *args);
virtual jdouble JNICALL CallDoubleMethod(jobject obj, jmethodID methodID, ...);
virtual jdouble JNICALL CallDoubleMethodV(jobject obj, jmethodID methodID, va_list args);
virtual jdouble JNICALL CallDoubleMethodA(jobject obj, jmethodID methodID, jvalue *args);
virtual void JNICALL CallVoidMethod(jobject obj, jmethodID methodID, ...);
virtual void JNICALL CallVoidMethodV(jobject obj, jmethodID methodID, va_list args);
virtual void JNICALL CallVoidMethodA(jobject obj, jmethodID methodID, jvalue * args);
virtual jobject JNICALL CallNonvirtualObjectMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
virtual jobject JNICALL CallNonvirtualObjectMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
virtual jobject JNICALL CallNonvirtualObjectMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
virtual jboolean JNICALL CallNonvirtualBooleanMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
virtual jboolean JNICALL CallNonvirtualBooleanMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
virtual jboolean JNICALL CallNonvirtualBooleanMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
virtual jbyte JNICALL CallNonvirtualByteMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
virtual jbyte JNICALL CallNonvirtualByteMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
virtual jbyte JNICALL CallNonvirtualByteMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
virtual jchar JNICALL CallNonvirtualCharMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
virtual jchar JNICALL CallNonvirtualCharMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
virtual jchar JNICALL CallNonvirtualCharMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
virtual jshort JNICALL CallNonvirtualShortMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
virtual jshort JNICALL CallNonvirtualShortMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
virtual jshort JNICALL CallNonvirtualShortMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
virtual jint JNICALL CallNonvirtualIntMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
virtual jint JNICALL CallNonvirtualIntMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
virtual jint JNICALL CallNonvirtualIntMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
virtual jlong JNICALL CallNonvirtualLongMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
virtual jlong JNICALL CallNonvirtualLongMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
virtual jlong JNICALL CallNonvirtualLongMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
virtual jfloat JNICALL CallNonvirtualFloatMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
virtual jfloat JNICALL CallNonvirtualFloatMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
virtual jfloat JNICALL CallNonvirtualFloatMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
virtual jdouble JNICALL CallNonvirtualDoubleMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
virtual jdouble JNICALL CallNonvirtualDoubleMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
virtual jdouble JNICALL CallNonvirtualDoubleMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
virtual void JNICALL CallNonvirtualVoidMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
virtual void JNICALL CallNonvirtualVoidMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
virtual void JNICALL CallNonvirtualVoidMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
virtual jfieldID JNICALL GetFieldID(jclass clazz, const char *name, const char *sig);
virtual jobject JNICALL GetObjectField(jobject obj, jfieldID fieldID);
virtual jboolean JNICALL GetBooleanField(jobject obj, jfieldID fieldID);
virtual jbyte JNICALL GetByteField(jobject obj, jfieldID fieldID);
virtual jchar JNICALL GetCharField(jobject obj, jfieldID fieldID);
virtual jshort JNICALL GetShortField(jobject obj, jfieldID fieldID);
virtual jint JNICALL GetIntField(jobject obj, jfieldID fieldID);
virtual jlong JNICALL GetLongField(jobject obj, jfieldID fieldID);
virtual jfloat JNICALL GetFloatField(jobject obj, jfieldID fieldID);
virtual jdouble JNICALL GetDoubleField(jobject obj, jfieldID fieldID);
virtual void JNICALL SetObjectField(jobject obj, jfieldID fieldID, jobject val);
virtual void JNICALL SetBooleanField(jobject obj, jfieldID fieldID, jboolean val);
virtual void JNICALL SetByteField(jobject obj, jfieldID fieldID, jbyte val);
virtual void JNICALL SetCharField(jobject obj, jfieldID fieldID, jchar val);
virtual void JNICALL SetShortField(jobject obj, jfieldID fieldID, jshort val);
virtual void JNICALL SetIntField(jobject obj, jfieldID fieldID, jint val);
virtual void JNICALL SetLongField(jobject obj, jfieldID fieldID, jlong val);
virtual void JNICALL SetFloatField(jobject obj, jfieldID fieldID, jfloat val);
virtual void JNICALL SetDoubleField(jobject obj, jfieldID fieldID, jdouble val);
virtual jmethodID JNICALL GetStaticMethodID(jclass clazz, const char *name, const char *sig);
virtual jobject JNICALL CallStaticObjectMethod(jclass clazz, jmethodID methodID, ...);
virtual jobject JNICALL CallStaticObjectMethodV(jclass clazz, jmethodID methodID, va_list args);
virtual jobject JNICALL CallStaticObjectMethodA(jclass clazz, jmethodID methodID, jvalue *args);
virtual jboolean JNICALL CallStaticBooleanMethod(jclass clazz, jmethodID methodID, ...);
virtual jboolean JNICALL CallStaticBooleanMethodV(jclass clazz, jmethodID methodID, va_list args);
virtual jboolean JNICALL CallStaticBooleanMethodA(jclass clazz, jmethodID methodID, jvalue *args);
virtual jbyte JNICALL CallStaticByteMethod(jclass clazz, jmethodID methodID, ...);
virtual jbyte JNICALL CallStaticByteMethodV(jclass clazz, jmethodID methodID, va_list args);
virtual jbyte JNICALL CallStaticByteMethodA(jclass clazz, jmethodID methodID, jvalue *args);
virtual jchar JNICALL CallStaticCharMethod(jclass clazz, jmethodID methodID, ...);
virtual jchar JNICALL CallStaticCharMethodV(jclass clazz, jmethodID methodID, va_list args);
virtual jchar JNICALL CallStaticCharMethodA(jclass clazz, jmethodID methodID, jvalue *args);
virtual jshort JNICALL CallStaticShortMethod(jclass clazz, jmethodID methodID, ...);
virtual jshort JNICALL CallStaticShortMethodV(jclass clazz, jmethodID methodID, va_list args);
virtual jshort JNICALL CallStaticShortMethodA(jclass clazz, jmethodID methodID, jvalue *args);
virtual jint JNICALL CallStaticIntMethod(jclass clazz, jmethodID methodID, ...);
virtual jint JNICALL CallStaticIntMethodV(jclass clazz, jmethodID methodID, va_list args);
virtual jint JNICALL CallStaticIntMethodA(jclass clazz, jmethodID methodID, jvalue *args);
virtual jlong JNICALL CallStaticLongMethod(jclass clazz, jmethodID methodID, ...);
virtual jlong JNICALL CallStaticLongMethodV(jclass clazz, jmethodID methodID, va_list args);
virtual jlong JNICALL CallStaticLongMethodA(jclass clazz, jmethodID methodID, jvalue *args);
virtual jfloat JNICALL CallStaticFloatMethod(jclass clazz, jmethodID methodID, ...);
virtual jfloat JNICALL CallStaticFloatMethodV(jclass clazz, jmethodID methodID, va_list args);
virtual jfloat JNICALL CallStaticFloatMethodA(jclass clazz, jmethodID methodID, jvalue *args);
virtual jdouble JNICALL CallStaticDoubleMethod(jclass clazz, jmethodID methodID, ...);
virtual jdouble JNICALL CallStaticDoubleMethodV(jclass clazz, jmethodID methodID, va_list args);
virtual jdouble JNICALL CallStaticDoubleMethodA(jclass clazz, jmethodID methodID, jvalue *args);
virtual void JNICALL CallStaticVoidMethod(jclass cls, jmethodID methodID, ...);
virtual void JNICALL CallStaticVoidMethodV(jclass cls, jmethodID methodID, va_list args);
virtual void JNICALL CallStaticVoidMethodA(jclass cls, jmethodID methodID, jvalue * args);
virtual jfieldID JNICALL GetStaticFieldID(jclass clazz, const char *name, const char *sig);
virtual jobject JNICALL GetStaticObjectField(jclass clazz, jfieldID fieldID);
virtual jboolean JNICALL GetStaticBooleanField(jclass clazz, jfieldID fieldID);
virtual jbyte JNICALL GetStaticByteField(jclass clazz, jfieldID fieldID);
virtual jchar JNICALL GetStaticCharField(jclass clazz, jfieldID fieldID);
virtual jshort JNICALL GetStaticShortField(jclass clazz, jfieldID fieldID);
virtual jint JNICALL GetStaticIntField(jclass clazz, jfieldID fieldID);
virtual jlong JNICALL GetStaticLongField(jclass clazz, jfieldID fieldID);
virtual jfloat JNICALL GetStaticFloatField(jclass clazz, jfieldID fieldID);
virtual jdouble JNICALL GetStaticDoubleField(jclass clazz, jfieldID fieldID);
virtual void JNICALL SetStaticObjectField(jclass clazz, jfieldID fieldID, jobject value);
virtual void JNICALL SetStaticBooleanField(jclass clazz, jfieldID fieldID, jboolean value);
virtual void JNICALL SetStaticByteField(jclass clazz, jfieldID fieldID, jbyte value);
virtual void JNICALL SetStaticCharField(jclass clazz, jfieldID fieldID, jchar value);
virtual void JNICALL SetStaticShortField(jclass clazz, jfieldID fieldID, jshort value);
virtual void JNICALL SetStaticIntField(jclass clazz, jfieldID fieldID, jint value);
virtual void JNICALL SetStaticLongField(jclass clazz, jfieldID fieldID, jlong value);
virtual void JNICALL SetStaticFloatField(jclass clazz, jfieldID fieldID, jfloat value);
virtual void JNICALL SetStaticDoubleField(jclass clazz, jfieldID fieldID, jdouble value);
virtual jstring JNICALL NewString(const jchar *unicode, jsize len);
virtual jsize JNICALL GetStringLength(jstring str);
virtual const jchar *JNICALL GetStringChars(jstring str, jboolean *isCopy);
virtual void JNICALL ReleaseStringChars(jstring str, const jchar *chars);
virtual jstring JNICALL NewStringUTF(const char *utf);
virtual jsize JNICALL GetStringUTFLength(jstring str);
virtual const char* JNICALL GetStringUTFChars(jstring str, jboolean *isCopy);
virtual void JNICALL ReleaseStringUTFChars(jstring str, const char* chars);
virtual jsize JNICALL GetArrayLength(jarray array);
virtual jobjectArray JNICALL NewObjectArray(jsize len, jclass clazz, jobject init);
virtual jobject JNICALL GetObjectArrayElement(jobjectArray array, jsize index);
virtual void JNICALL SetObjectArrayElement(jobjectArray array, jsize index, jobject val);
virtual jbooleanArray JNICALL NewBooleanArray(jsize len);
virtual jbyteArray JNICALL NewByteArray(jsize len);
virtual jcharArray JNICALL NewCharArray(jsize len);
virtual jshortArray JNICALL NewShortArray(jsize len);
virtual jintArray JNICALL NewIntArray(jsize len);
virtual jlongArray JNICALL NewLongArray(jsize len);
virtual jfloatArray JNICALL NewFloatArray(jsize len);
virtual jdoubleArray JNICALL NewDoubleArray(jsize len);
virtual jboolean * JNICALL GetBooleanArrayElements(jbooleanArray array, jboolean *isCopy);
virtual jbyte * JNICALL GetByteArrayElements(jbyteArray array, jboolean *isCopy);
virtual jchar * JNICALL GetCharArrayElements(jcharArray array, jboolean *isCopy);
virtual jshort * JNICALL GetShortArrayElements(jshortArray array, jboolean *isCopy);
virtual jint * JNICALL GetIntArrayElements(jintArray array, jboolean *isCopy);
virtual jlong * JNICALL GetLongArrayElements(jlongArray array, jboolean *isCopy);
virtual jfloat * JNICALL GetFloatArrayElements(jfloatArray array, jboolean *isCopy);
virtual jdouble * JNICALL GetDoubleArrayElements(jdoubleArray array, jboolean *isCopy);
virtual void JNICALL ReleaseBooleanArrayElements(jbooleanArray array, jboolean *elems, jint mode);
virtual void JNICALL ReleaseByteArrayElements(jbyteArray array, jbyte *elems, jint mode);
virtual void JNICALL ReleaseCharArrayElements(jcharArray array, jchar *elems, jint mode);
virtual void JNICALL ReleaseShortArrayElements(jshortArray array, jshort *elems, jint mode);
virtual void JNICALL ReleaseIntArrayElements(jintArray array, jint *elems, jint mode);
virtual void JNICALL ReleaseLongArrayElements(jlongArray array, jlong *elems, jint mode);
virtual void JNICALL ReleaseFloatArrayElements(jfloatArray array, jfloat *elems, jint mode);
virtual void JNICALL ReleaseDoubleArrayElements(jdoubleArray array, jdouble *elems, jint mode);
virtual void JNICALL GetBooleanArrayRegion(jbooleanArray array, jsize start, jsize l, jboolean *buf);
virtual void JNICALL GetByteArrayRegion(jbyteArray array, jsize start, jsize len, jbyte *buf);
virtual void JNICALL GetCharArrayRegion(jcharArray array, jsize start, jsize len, jchar *buf);
virtual void JNICALL GetShortArrayRegion(jshortArray array, jsize start, jsize len, jshort *buf);
virtual void JNICALL GetIntArrayRegion(jintArray array, jsize start, jsize len, jint *buf);
virtual void JNICALL GetLongArrayRegion(jlongArray array, jsize start, jsize len, jlong *buf);
virtual void JNICALL GetFloatArrayRegion(jfloatArray array, jsize start, jsize len, jfloat *buf);
virtual void JNICALL GetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, jdouble *buf);
virtual void JNICALL SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize l, jboolean *buf);
virtual void JNICALL SetByteArrayRegion(jbyteArray array, jsize start, jsize len, jbyte *buf);
virtual void JNICALL SetCharArrayRegion(jcharArray array, jsize start, jsize len, jchar *buf);
virtual void JNICALL SetShortArrayRegion(jshortArray array, jsize start, jsize len, jshort *buf);
virtual void JNICALL SetIntArrayRegion(jintArray array, jsize start, jsize len, jint *buf);
virtual void JNICALL SetLongArrayRegion(jlongArray array, jsize start, jsize len, jlong *buf);
virtual void JNICALL SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, jfloat *buf);
virtual void JNICALL SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, jdouble *buf);
virtual jint JNICALL RegisterNatives(jclass clazz, const JNINativeMethod *methods, jint nMethods);
virtual jint JNICALL UnregisterNatives(jclass clazz);
virtual jint JNICALL MonitorEnter(jobject obj);
virtual jint JNICALL MonitorExit(jobject obj);
virtual jint JNICALL GetJavaVM(JavaVM **vm);
virtual void JNICALL GetStringRegion(jstring str, jsize start, jsize len, jchar *buf);
virtual void JNICALL GetStringUTFRegion(jstring str, jsize start, jsize len, char *buf);
virtual void* JNICALL GetPrimitiveArrayCritical(jarray array, jboolean *isCopy);
virtual void JNICALL ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode);
virtual const jchar* JNICALL GetStringCritical(jstring string, jboolean *isCopy);
virtual void JNICALL ReleaseStringCritical(jstring string, const jchar *cstring);
virtual jweak JNICALL NewWeakGlobalRef(jobject obj);
virtual void JNICALL DeleteWeakGlobalRef(jweak ref);
virtual jboolean JNICALL ExceptionCheck();
virtual jobject JNICALL NewDirectByteBuffer(void* address, jlong capacity);
virtual void* JNICALL GetDirectBufferAddress(jobject buf);
virtual jlong JNICALL GetDirectBufferCapacity(jobject buf);
};
class JavaVM
{
public:
virtual void JNICALL reserved0();
virtual void JNICALL reserved1();
virtual void JNICALL reserved2();
virtual jint JNICALL DestroyJavaVM();
virtual jint JNICALL AttachCurrentThread(void **penv, void *args);
virtual jint JNICALL DetachCurrentThread();
virtual jint JNICALL GetEnv(void **penv, jint version);
virtual jint JNICALL AttachCurrentThreadAsDaemon(void **penv, void *args);
};

Просмотреть файл

@ -1,567 +0,0 @@
//
// JNI: a class used by IKVM.NET to access JNI related functionality.
//
//
// This is the mono version of the JNI provider. As much code is written in C#
// as possible. The code depends on having a non-copying garbage collector.
//
using System;
using System.Collections;
using System.Text;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
[assembly:AssemblyVersionAttribute("0.9.*")]
//[assembly:AssemblyKeyFile("c:\\ikvm-key\\ikvm.snk")]
public class VM
{
public static Exception UnsatisfiedLinkError (string msg) {
return JniHelper.UnsatisfiedLinkError (msg);
}
}
public class JNI : IJniProvider
{
static Hashtable modules = new Hashtable ();
[DllImport("mono-ikvm-jni")]
private static extern IntPtr native_load_native_library (string filename);
[DllImport("mono-ikvm-jni")]
private static extern bool native_lookup_symbol (IntPtr module, string symbol_name, ref int symbol);
[DllImport("gmodule-2.0")]
private static extern IntPtr g_module_open (string file_name, int flags);
[DllImport("gmodule-2.0")]
private static extern bool g_module_symbol (IntPtr module, string symbol_name, ref int symbol);
public int LoadNativeLibrary (string filename) {
Console.WriteLine ("LoadNativeLibrary : " + filename);
IntPtr module = g_module_open (filename, 0);
if (module == (IntPtr)0)
return 0;
modules [module] = filename;
return 1;
}
public Type GetLocalRefStructType () {
return typeof (IkvmJNIEnv);
}
public MethodInfo GetJniFuncPtrMethod () {
return typeof (JNI).GetMethod ("GetJniFuncPtr");
}
//
// Return a pointer to the C function implementing the given native
// method.
public static IntPtr GetJniFuncPtr (string method, string sig, string klass) {
// Console.WriteLine ("JNI_FUNC: " + method + " " + sig + " " + klass);
StringBuilder mangledSig = new StringBuilder ();
int sp = 0;
for (int i = 1; sig[i] != ')'; ++i) {
switch (sig[i]) {
case '[':
mangledSig.Append("_3");
sp += 4;
while(sig[++i] == '[')
mangledSig.Append("_3");
mangledSig.Append(sig[i]);
if(sig[i] == 'L') {
while(sig[++i] != ';') {
if(sig[i] == '/')
mangledSig.Append("_");
else if(sig[i] == '_')
mangledSig.Append("_1");
else
mangledSig.Append(sig[i]);
}
mangledSig.Append("_2");
}
break;
case 'L':
sp += 4;
mangledSig.Append("L");
while(sig[++i] != ';') {
if(sig[i] == '/')
mangledSig.Append("_");
else if(sig[i] == '_')
mangledSig.Append("_1");
else
mangledSig.Append(sig[i]);
}
mangledSig.Append("_2");
break;
case 'J':
case 'D':
mangledSig.Append(sig[i]);
sp += 8;
break;
case 'F':
case 'I':
case 'C':
case 'Z':
case 'S':
case 'B':
mangledSig.Append(sig[i]);
sp += 4;
break;
default:
throw new NotImplementedException();
}
}
string methodName = "";
for (int pass = 0; pass < 2; ++pass) {
methodName = String.Format ("Java_{0}_{1}", klass.Replace("_", "_1").Replace('/', '_'), method.Replace("_", "_1"));
if (pass == 1)
methodName = methodName + "__" + mangledSig;
Console.WriteLine ("METHOD_NAME1: " + methodName);
foreach (IntPtr module in modules.Keys) {
int function = 0;
bool found = g_module_symbol (module, methodName, ref function);
if (found) {
// Console.WriteLine ("FOUND IN " + modules[module] + " -> " + function);
return new IntPtr (function);
}
}
}
throw VM.UnsatisfiedLinkError(methodName);
}
}
//
// When running on a runtime with a non-copying collector, we can use object
// references instead of handles.
//
// Hackish struct used for ptr<->reference conversion
[StructLayout (LayoutKind.Sequential)]
struct PtrStruct {
public IntPtr ptr;
public object localref;
}
[StructLayout (LayoutKind.Sequential)]
class JNIEnv {
IntPtr func_table;
JNIEnv self;
object[] localrefs;
int localref_ptr;
public object pendingException;
GCHandle gc_handle;
public JNIEnv (IntPtr the_func_table) {
func_table = the_func_table;
localrefs = new object[32];
self = this;
/* Pin ourselves */
gc_handle = GCHandle.Alloc (this, GCHandleType.Pinned);
}
public IntPtr Enter () {
pendingException = null;
localref_ptr = 0;
return GetEnvPtr ();
}
public void Leave () {
if (localref_ptr > 0) {
for (int i = 0; i < localref_ptr; ++i)
localrefs [i] = null;
localref_ptr = 0;
}
}
public unsafe IntPtr GetEnvPtr () {
void *current;
fixed (void *p = &func_table) {
current = p;
}
return (IntPtr)current;
}
public unsafe static JNIEnv GetJniEnvFromEnvPtr (IntPtr ptr) {
/* FIXME: */
return (JNIEnv)ConvertToObject (*(IntPtr*)((long)ptr + 4));
}
public IntPtr MakeLocalRef (object o) {
#if COPYING_COLLECTOR
// Console.WriteLine ("MakeLocalRef.");
if (o == null)
return (IntPtr)0;
localrefs [localref_ptr] = o;
localref_ptr ++;
if (localref_ptr == localrefs.Length) {
object[] localrefs2 = new object [localrefs.Length * 2];
System.Array.Copy (localrefs, localrefs2, localrefs.Length);
localrefs = localrefs2;
}
return (IntPtr)(localref_ptr);
#else
return ConvertToPtr (o);
#endif
}
public unsafe void DeleteLocalRef (IntPtr localRef) {
#if COPYING_COLLECTOR
// Console.WriteLine ("DeleteLocalRef.");
int index = (int)localRef;
localrefs [index - 1] = null;
#endif
}
public unsafe object UnwrapLocalRef (IntPtr localRef) {
#if COPYING_COLLECTOR
// Console.WriteLine ("UnwrapLocalRef.");
int index = (int)localRef;
if (index == 0)
return null;
else
return localrefs [index - 1];
#else
return ConvertToObject (localRef);
#endif
}
private unsafe static object ConvertToObject (IntPtr ptr) {
PtrStruct s;
s.ptr = ptr;
s.localref = null;
IntPtr *p = &s.ptr;
p [1] = ptr;
return s.localref;
}
private unsafe static IntPtr ConvertToPtr (object o) {
PtrStruct s;
s.localref = o;
IntPtr *p = &s.ptr;
return p [1];
}
}
[StructLayout (LayoutKind.Sequential)]
public unsafe struct IkvmJNIEnv {
JNIEnv env;
// This should be the first field in the structure
IntPtr func_table;
#if COPYING_COLLECTOR
// Allocate most of the array in-line
IntPtr localref0;
object localref1;
object localref2;
object localref3;
object localref4;
object localref5;
object localref6;
object localref7;
object localref8;
object localref9;
object localref10;
object localref11;
object localref12;
object localref13;
object localref14;
object localref15;
object localref16;
object[] localrefs;
int localref_ptr;
#endif
[ThreadStatic]
static JNIEnv current;
void* previous;
public static IntPtr the_func_table;
static ArrayList globalRefs;
static int t_count = 0;
//
// Called before entering a native method
//
public IntPtr Enter () {
env = current;
if (env == null) {
env = new JNIEnv (the_func_table);
current = env;
}
return env.Enter ();
}
//
// Called after leaving a native method
//
public void Leave () {
env.Leave ();
}
public IntPtr MakeLocalRef (object o) {
return env.MakeLocalRef (o);
}
public unsafe object UnwrapLocalRef (IntPtr localRef) {
return env.UnwrapLocalRef (localRef);
}
[DllImport("mono-ikvm-jni")]
private static extern IntPtr mono_jni_get_func_table ();
[DllImport("mono-ikvm-jni")]
private static extern int mono_jni_jnienv_init (
Delegate makelocalref_func,
Delegate unwind_func,
Delegate makeglobalref_func,
Delegate deleteglobalref_func,
Delegate getfieldcookie_func,
Delegate getmethodcookie_func,
Delegate setfieldvalue_func,
Delegate getfieldvalue_func,
Delegate getclassfromobject_func,
Delegate exceptioncheck_func,
Delegate getpendingexception_func,
Delegate setpendingexception_func,
Delegate invokemethod_func,
Delegate getmethodarglist_func,
Delegate findclass_func,
Delegate getjnienv_func,
Delegate allocobject_func);
[DllImport("mono-ikvm-jni")]
public extern static void mono_jni_set_jnifunc (int index, Delegate func);
static IkvmJNIEnv () {
Console.WriteLine ("INIT");
globalRefs = new ArrayList ();
mono_jni_jnienv_init (
new MakeLocalRefDelegate (HelperMakeLocalRef),
new UnwrapRefDelegate (HelperUnwrapRef),
new MakeGlobalRefDelegate (MakeGlobalRef),
new DeleteRefDelegate (DeleteRef),
new GetFieldCookieDelegate (GetFieldCookie),
new GetMethodCookieDelegate (GetMethodCookie),
new SetFieldValueDelegate (SetFieldValue),
new GetFieldValueDelegate (GetFieldValue),
new GetClassFromObjectDelegate (GetClassFromObject),
new ExceptionCheckDelegate (ExceptionCheck),
new GetPendingExceptionDelegate (GetPendingException),
new SetPendingExceptionDelegate (SetPendingException),
new InvokeMethodDelegate (InvokeMethod),
new GetMethodArgListDelegate (GetMethodArgList),
new FindClassDelegate (FindClass),
new GetJniEnvDelegate (GetJniEnv),
new AllocObjectDelegate (JniHelper.AllocObject));
the_func_table = mono_jni_get_func_table ();
}
private static object ConvertToObject (IntPtr ptr) {
PtrStruct s;
s.ptr = ptr;
s.localref = null;
IntPtr *p = &s.ptr;
p [1] = ptr;
return s.localref;
}
private static IntPtr ConvertToPtr (object o) {
PtrStruct s;
s.localref = o;
IntPtr *p = &s.ptr;
return p [1];
}
/*
// Return the address of the 'func_table' member from a boxed JNIEnv object
// Implemented in IL
private static IntPtr GetJniEnvPtr (object o) {
return null;
}
*/
//
// Methods called by the native code
//
public delegate IntPtr MakeLocalRefDelegate (IntPtr jniEnv, object obj);
public static unsafe IntPtr HelperMakeLocalRef (IntPtr jniEnv, object obj) {
#if COPYING_COLLECTOR
return JNIEnv.GetJniEnvFromEnvPtr (jniEnv).MakeLocalRef (obj);
#else
return ConvertToPtr (obj);
#endif
}
public delegate object UnwrapRefDelegate (IntPtr jniEnv, IntPtr reference);
public static unsafe object HelperUnwrapRef (IntPtr jniEnv, IntPtr reference) {
#if COPYING_COLLECTOR
if ((int)reference >= 0)
return JNIEnv.GetJniEnvFromEnvPtr (jniEnv).UnwrapLocalRef (reference);
else
return globalRefs [(- (int)reference) - 1];
#else
return ConvertToObject (reference);
#endif
}
public delegate IntPtr MakeGlobalRefDelegate (object obj);
public static IntPtr MakeGlobalRef (object obj) {
#if COPYING_COLLECTOR
if (obj == null)
return (IntPtr)0;
else
return (IntPtr)(- (globalRefs.Add (obj) + 1));
#else
return ConvertToPtr (obj);
#endif
}
public delegate void DeleteRefDelegate (IntPtr jniEnv, IntPtr reference);
public static unsafe void DeleteRef (IntPtr jniEnv, IntPtr reference) {
#if COPYING_COLLECTOR
if ((int)reference == 0)
return;
else
if ((int)reference > 0)
JNIEnv.GetJniEnvFromEnvPtr (jniEnv).DeleteLocalRef (reference);
else {
int index = (- (int)reference) - 1;
globalRefs [index] = null;
}
#endif
}
public delegate IntPtr GetFieldCookieDelegate(object clazz, object name, object sig, bool isStatic);
public static IntPtr GetFieldCookie(object clazz, object name, object sig, bool isStatic) {
IntPtr res = JniHelper.GetFieldCookie (clazz, (string)name, (string)sig, isStatic);
return res;
/*
if ((int)res == 0)
throw new NotImplementedException ();
else
return res;
*/
}
public delegate IntPtr GetMethodCookieDelegate (object clazz, object name, object sig, bool isStatic);
public static IntPtr GetMethodCookie(object clazz, object name, object sig, bool isStatic) {
IntPtr res = JniHelper.GetMethodCookie (clazz, (string)name, (string)sig, isStatic);
return res;
/*
if ((int)res == 0)
throw new NotImplementedException ();
else
return res;
*/
}
public delegate void SetFieldValueDelegate(IntPtr cookie, object obj, object val);
public static void SetFieldValue (IntPtr cookie, object obj, object val) {
JniHelper.SetFieldValue (cookie, obj, val);
}
public delegate object GetFieldValueDelegate (IntPtr cookie, object obj);
public static object GetFieldValue (IntPtr cookie, object obj) {
return JniHelper.GetFieldValue (cookie, obj);
}
public delegate object GetClassFromObjectDelegate (object obj);
public static object GetClassFromObject (object obj) {
return JniHelper.GetClassFromType (obj.GetType ());
}
public delegate bool ExceptionCheckDelegate (IntPtr jniEnv);
public static unsafe bool ExceptionCheck (IntPtr jniEnv) {
if (JNIEnv.GetJniEnvFromEnvPtr (jniEnv).pendingException == null)
return false;
else
return true;
}
public delegate object GetPendingExceptionDelegate (IntPtr jniEnv);
public static unsafe object GetPendingException (IntPtr jniEnv) {
return JNIEnv.GetJniEnvFromEnvPtr (jniEnv).pendingException;
}
public delegate void SetPendingExceptionDelegate (IntPtr jniEnv, object obj);
public static unsafe void SetPendingException (IntPtr jniEnv, object obj) {
JNIEnv.GetJniEnvFromEnvPtr (jniEnv).pendingException = obj;
}
public delegate object InvokeMethodDelegate (IntPtr jniEnv, IntPtr cookie, object obj, object args, bool nonVirtual);
public static object InvokeMethod (IntPtr jniEnv, IntPtr cookie, object obj, object args, bool nonVirtual) {
try {
return JniHelper.InvokeMethod (cookie, obj, (object[])args, nonVirtual);
}
catch (Exception ex) {
SetPendingException (jniEnv, ex);
return null;
}
}
public delegate string GetMethodArgListDelegate (IntPtr cookie);
public static string GetMethodArgList (IntPtr cookie) {
return JniHelper.GetMethodArgList (cookie);
}
public delegate object FindClassDelegate (object javaName);
public static object FindClass (object javaName) {
return JniHelper.FindClass ((string)javaName);
}
public unsafe delegate IntPtr GetJniEnvDelegate ();
public static unsafe IntPtr GetJniEnv () {
return current.GetEnvPtr ();
}
public delegate object AllocObjectDelegate (object clazz);
}

Просмотреть файл

@ -1,14 +0,0 @@
<?xml version="1.0"?>
<project name="IKVM.JNI.Mono" default="all">
<target name="all">
<csc target="library" output="../../bin/IKVM.JNI.Mono.dll" define="TRACE">
<sources>
<includes name="JNI.cs" />
</sources>
<arg value="-unsafe"/>
<references>
<includes name="../../bin/IKVM.Runtime.dll" asis="true" />
</references>
</csc>
</target>
</project>

500
native/jni.c Normal file
Просмотреть файл

@ -0,0 +1,500 @@
/*
Copyright (C) 2004 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
#include <stdarg.h>
#include <malloc.h>
#include "jni.h"
#ifdef _WIN32
#define ALLOCA _alloca
#else
#include <alloca.h>
#define ALLOCA alloca
#endif
static jobject JNICALL NewObject(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...)
{
jobject o;
va_list args;
va_start(args, methodID);
o = (*pEnv)->NewObjectV(pEnv, clazz, methodID, args);
va_end(args);
return o;
}
#define MAKE_ARG_ARRAY(pEnv, args, argarray) \
do { \
jbyte sig[257];\
int argc = (*pEnv)->GetMethodArgs(pEnv, methodID, sig);\
int i;\
argarray = (jvalue*)ALLOCA(argc * sizeof(jvalue));\
for(i = 0; i < argc; i++)\
{\
switch(sig[i])\
{\
case 'Z':\
case 'B':\
case 'S':\
case 'C':\
case 'I':\
argarray[i].i = va_arg(args, jint);\
break;\
case 'J':\
argarray[i].j = va_arg(args, jlong);\
break;\
case 'L':\
argarray[i].l = va_arg(args, jobject);\
break;\
case 'D':\
argarray[i].d = va_arg(args, double);\
break;\
case 'F':\
argarray[i].f = (float)va_arg(args, double);\
break;\
}\
}\
} while(0);
static jobject JNICALL NewObjectV(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args)
{
jvalue* argarray;
MAKE_ARG_ARRAY(pEnv, args, argarray);
return (*pEnv)->NewObjectA(pEnv, clazz, methodID, argarray);
}
#define MAKE_METHOD(Type, type) \
static type JNICALL Call##Type##Method(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...)\
{\
type ret;\
va_list args;\
va_start(args, methodID);\
ret = (*pEnv)->Call##Type##MethodV(pEnv, obj, methodID, args);\
va_end(args);\
return ret;\
}\
static type JNICALL Call##Type##MethodV(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args)\
{\
jvalue* argarray;\
MAKE_ARG_ARRAY(pEnv, args, argarray);\
return (*pEnv)->Call##Type##MethodA(pEnv, obj, methodID, argarray);\
}\
static type JNICALL CallNonvirtual##Type##Method(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...)\
{\
type ret;\
va_list args;\
va_start(args, methodID);\
ret = (*pEnv)->CallNonvirtual##Type##MethodV(pEnv, obj, clazz, methodID, args);\
va_end(args);\
return ret;\
}\
static type JNICALL CallNonvirtual##Type##MethodV(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args)\
{\
jvalue* argarray;\
MAKE_ARG_ARRAY(pEnv, args, argarray);\
return (*pEnv)->CallNonvirtual##Type##MethodA(pEnv, obj, clazz, methodID, argarray);\
}\
static type JNICALL CallStatic##Type##Method(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...)\
{\
type ret;\
va_list args;\
va_start(args, methodID);\
ret = (*pEnv)->CallStatic##Type##MethodV(pEnv, clazz, methodID, args);\
va_end(args);\
return ret;\
}\
static type JNICALL CallStatic##Type##MethodV(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args)\
{\
jvalue* argarray;\
MAKE_ARG_ARRAY(pEnv, args, argarray);\
return (*pEnv)->CallStatic##Type##MethodA(pEnv, clazz, methodID, argarray);\
}
MAKE_METHOD(Object, jobject)
MAKE_METHOD(Boolean, jboolean)
MAKE_METHOD(Byte, jbyte)
MAKE_METHOD(Char, jchar)
MAKE_METHOD(Short, jshort)
MAKE_METHOD(Int, jint)
MAKE_METHOD(Long, jlong)
MAKE_METHOD(Float, jfloat)
MAKE_METHOD(Double, jdouble)
static void JNICALL CallVoidMethod(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...)
{
va_list args;
va_start(args, methodID);
(*pEnv)->CallVoidMethodV(pEnv, obj, methodID, args);
va_end(args);
}
static void JNICALL CallVoidMethodV(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args)
{
jvalue* argarray;
MAKE_ARG_ARRAY(pEnv, args, argarray);
(*pEnv)->CallVoidMethodA(pEnv, obj, methodID, argarray);
}
static void JNICALL CallNonvirtualVoidMethod(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...)
{
va_list args;
va_start(args, methodID);
(*pEnv)->CallNonvirtualVoidMethodV(pEnv, obj, clazz, methodID, args);
va_end(args);
}
static void JNICALL CallNonvirtualVoidMethodV(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args)
{
jvalue* argarray;
MAKE_ARG_ARRAY(pEnv, args, argarray);
(*pEnv)->CallNonvirtualVoidMethodA(pEnv, obj, clazz, methodID, argarray);
}
static void JNICALL CallStaticVoidMethod(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...)
{
va_list args;
va_start(args, methodID);
(*pEnv)->CallStaticVoidMethodV(pEnv, clazz, methodID, args);
va_end(args);
}
static void JNICALL CallStaticVoidMethodV(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args)
{
jvalue* argarray;
MAKE_ARG_ARRAY(pEnv, args, argarray);
(*pEnv)->CallStaticVoidMethodA(pEnv, clazz, methodID, argarray);
}
static void* JNIEnv_vtable[] =
{
0, // void JNICALL reserved0();
0, // void JNICALL reserved1();
0, // void JNICALL reserved2();
0, // void JNICALL reserved3();
0, // jint JNICALL GetVersion();
0, // jclass JNICALL DefineClass(const char *name, jobject loader, const jbyte *buf, jsize len);
0, // jclass JNICALL FindClass(const char *name);
0, // jmethodID JNICALL FromReflectedMethod(jobject method);
0, // jfieldID JNICALL FromReflectedField(jobject field);
0, // jobject JNICALL ToReflectedMethod(jclass clazz, jmethodID methodID);
0, // jclass JNICALL GetSuperclass(jclass sub);
0, // jboolean JNICALL IsAssignableFrom(jclass sub, jclass sup);
0, // jobject JNICALL ToReflectedField(jclass clazz, jfieldID fieldID);
0, // jint JNICALL Throw(jthrowable obj);
0, // jint JNICALL ThrowNew(jclass clazz, const char *msg);
0, // jthrowable JNICALL ExceptionOccurred();
0, // void JNICALL ExceptionDescribe();
0, // void JNICALL ExceptionClear();
0, // void JNICALL FatalError(const char *msg);
0, // jint JNICALL PushLocalFrame(jint capacity);
0, // jobject JNICALL PopLocalFrame(jobject result);
0, // jobject JNICALL NewGlobalRef(jobject lobj);
0, // void JNICALL DeleteGlobalRef(jobject gref);
0, // void JNICALL DeleteLocalRef(jobject obj);
0, // jboolean JNICALL IsSameObject(jobject obj1, jobject obj2);
0, // jobject JNICALL NewLocalRef(jobject ref);
0, // jint JNICALL EnsureLocalCapacity(jint capacity);
0, // jobject JNICALL AllocObject(jclass clazz);
NewObject, // jobject JNICALL NewObject(jclass clazz, jmethodID methodID, ...);
NewObjectV, // jobject JNICALL NewObjectV(jclass clazz, jmethodID methodID, va_list args);
0, // jobject JNICALL NewObjectA(jclass clazz, jmethodID methodID, jvalue *args);
0, // jclass JNICALL GetObjectClass(jobject obj);
0, // jboolean JNICALL IsInstanceOf(jobject obj, jclass clazz);
0, // jmethodID JNICALL GetMethodID(jclass clazz, const char *name, const char *sig);
CallObjectMethod, // jobject JNICALL CallObjectMethod(jobject obj, jmethodID methodID, ...);
CallObjectMethodV, // jobject JNICALL CallObjectMethodV(jobject obj, jmethodID methodID, va_list args);
0, // jobject JNICALL CallObjectMethodA(jobject obj, jmethodID methodID, jvalue * args);
CallBooleanMethod, // jboolean JNICALL CallBooleanMethod(jobject obj, jmethodID methodID, ...);
CallBooleanMethodV, // jboolean JNICALL CallBooleanMethodV(jobject obj, jmethodID methodID, va_list args);
0, // jboolean JNICALL CallBooleanMethodA(jobject obj, jmethodID methodID, jvalue * args);
CallByteMethod, // jbyte JNICALL CallByteMethod(jobject obj, jmethodID methodID, ...);
CallByteMethodV, // jbyte JNICALL CallByteMethodV(jobject obj, jmethodID methodID, va_list args);
0, // jbyte JNICALL CallByteMethodA(jobject obj, jmethodID methodID, jvalue *args);
CallCharMethod, // jchar JNICALL CallCharMethod(jobject obj, jmethodID methodID, ...);
CallCharMethodV, // jchar JNICALL CallCharMethodV(jobject obj, jmethodID methodID, va_list args);
0, // jchar JNICALL CallCharMethodA(jobject obj, jmethodID methodID, jvalue *args);
CallShortMethod, // jshort JNICALL CallShortMethod(jobject obj, jmethodID methodID, ...);
CallShortMethodV, // jshort JNICALL CallShortMethodV(jobject obj, jmethodID methodID, va_list args);
0, // jshort JNICALL CallShortMethodA(jobject obj, jmethodID methodID, jvalue *args);
CallIntMethod, // jint JNICALL CallIntMethod(jobject obj, jmethodID methodID, ...);
CallIntMethodV, // jint JNICALL CallIntMethodV(jobject obj, jmethodID methodID, va_list args);
0, // jint JNICALL CallIntMethodA(jobject obj, jmethodID methodID, jvalue *args);
CallLongMethod, // jlong JNICALL CallLongMethod(jobject obj, jmethodID methodID, ...);
CallLongMethodV, // jlong JNICALL CallLongMethodV(jobject obj, jmethodID methodID, va_list args);
0, // jlong JNICALL CallLongMethodA(jobject obj, jmethodID methodID, jvalue *args);
CallFloatMethod, // jfloat JNICALL CallFloatMethod(jobject obj, jmethodID methodID, ...);
CallFloatMethodV, // jfloat JNICALL CallFloatMethodV(jobject obj, jmethodID methodID, va_list args);
0, // jfloat JNICALL CallFloatMethodA(jobject obj, jmethodID methodID, jvalue *args);
CallDoubleMethod, // jdouble JNICALL CallDoubleMethod(jobject obj, jmethodID methodID, ...);
CallDoubleMethodV, // jdouble JNICALL CallDoubleMethodV(jobject obj, jmethodID methodID, va_list args);
0, // jdouble JNICALL CallDoubleMethodA(jobject obj, jmethodID methodID, jvalue *args);
CallVoidMethod, // void JNICALL CallVoidMethod(jobject obj, jmethodID methodID, ...);
CallVoidMethodV, // void JNICALL CallVoidMethodV(jobject obj, jmethodID methodID, va_list args);
0, // void JNICALL CallVoidMethodA(jobject obj, jmethodID methodID, jvalue * args);
CallNonvirtualObjectMethod, // jobject JNICALL CallNonvirtualObjectMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
CallNonvirtualObjectMethodV, // jobject JNICALL CallNonvirtualObjectMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
0, // jobject JNICALL CallNonvirtualObjectMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
CallNonvirtualBooleanMethod, // jboolean JNICALL CallNonvirtualBooleanMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
CallNonvirtualBooleanMethodV, // jboolean JNICALL CallNonvirtualBooleanMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
0, // jboolean JNICALL CallNonvirtualBooleanMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
CallNonvirtualByteMethod, // jbyte JNICALL CallNonvirtualByteMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
CallNonvirtualByteMethodV, // jbyte JNICALL CallNonvirtualByteMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
0, // jbyte JNICALL CallNonvirtualByteMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
CallNonvirtualCharMethod, // jchar JNICALL CallNonvirtualCharMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
CallNonvirtualCharMethodV, // jchar JNICALL CallNonvirtualCharMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
0, // jchar JNICALL CallNonvirtualCharMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
CallNonvirtualShortMethod, // jshort JNICALL CallNonvirtualShortMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
CallNonvirtualShortMethodV, // jshort JNICALL CallNonvirtualShortMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
0, // jshort JNICALL CallNonvirtualShortMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
CallNonvirtualIntMethod, // jint JNICALL CallNonvirtualIntMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
CallNonvirtualIntMethodV, // jint JNICALL CallNonvirtualIntMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
0, // jint JNICALL CallNonvirtualIntMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
CallNonvirtualLongMethod, // jlong JNICALL CallNonvirtualLongMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
CallNonvirtualLongMethodV, // jlong JNICALL CallNonvirtualLongMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
0, // jlong JNICALL CallNonvirtualLongMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
CallNonvirtualFloatMethod, // jfloat JNICALL CallNonvirtualFloatMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
CallNonvirtualFloatMethodV, // jfloat JNICALL CallNonvirtualFloatMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
0, // jfloat JNICALL CallNonvirtualFloatMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
CallNonvirtualDoubleMethod, // jdouble JNICALL CallNonvirtualDoubleMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
CallNonvirtualDoubleMethodV, // jdouble JNICALL CallNonvirtualDoubleMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
0, // jdouble JNICALL CallNonvirtualDoubleMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
CallNonvirtualVoidMethod, // void JNICALL CallNonvirtualVoidMethod(jobject obj, jclass clazz, jmethodID methodID, ...);
CallNonvirtualVoidMethodV, // void JNICALL CallNonvirtualVoidMethodV(jobject obj, jclass clazz, jmethodID methodID, va_list args);
0, // void JNICALL CallNonvirtualVoidMethodA(jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
0, // jfieldID JNICALL GetFieldID(jclass clazz, const char *name, const char *sig);
0, // jobject JNICALL GetObjectField(jobject obj, jfieldID fieldID);
0, // jboolean JNICALL GetBooleanField(jobject obj, jfieldID fieldID);
0, // jbyte JNICALL GetByteField(jobject obj, jfieldID fieldID);
0, // jchar JNICALL GetCharField(jobject obj, jfieldID fieldID);
0, // jshort JNICALL GetShortField(jobject obj, jfieldID fieldID);
0, // jint JNICALL GetIntField(jobject obj, jfieldID fieldID);
0, // jlong JNICALL GetLongField(jobject obj, jfieldID fieldID);
0, // jfloat JNICALL GetFloatField(jobject obj, jfieldID fieldID);
0, // jdouble JNICALL GetDoubleField(jobject obj, jfieldID fieldID);
0, // void JNICALL SetObjectField(jobject obj, jfieldID fieldID, jobject val);
0, // void JNICALL SetBooleanField(jobject obj, jfieldID fieldID, jboolean val);
0, // void JNICALL SetByteField(jobject obj, jfieldID fieldID, jbyte val);
0, // void JNICALL SetCharField(jobject obj, jfieldID fieldID, jchar val);
0, // void JNICALL SetShortField(jobject obj, jfieldID fieldID, jshort val);
0, // void JNICALL SetIntField(jobject obj, jfieldID fieldID, jint val);
0, // void JNICALL SetLongField(jobject obj, jfieldID fieldID, jlong val);
0, // void JNICALL SetFloatField(jobject obj, jfieldID fieldID, jfloat val);
0, // void JNICALL SetDoubleField(jobject obj, jfieldID fieldID, jdouble val);
0, // jmethodID JNICALL GetStaticMethodID(jclass clazz, const char *name, const char *sig);
CallStaticObjectMethod, // jobject JNICALL CallStaticObjectMethod(jclass clazz, jmethodID methodID, ...);
CallStaticObjectMethodV, // jobject JNICALL CallStaticObjectMethodV(jclass clazz, jmethodID methodID, va_list args);
0, // jobject JNICALL CallStaticObjectMethodA(jclass clazz, jmethodID methodID, jvalue *args);
CallStaticBooleanMethod, // jboolean JNICALL CallStaticBooleanMethod(jclass clazz, jmethodID methodID, ...);
CallStaticBooleanMethodV, // jboolean JNICALL CallStaticBooleanMethodV(jclass clazz, jmethodID methodID, va_list args);
0, // jboolean JNICALL CallStaticBooleanMethodA(jclass clazz, jmethodID methodID, jvalue *args);
CallStaticByteMethod, // jbyte JNICALL CallStaticByteMethod(jclass clazz, jmethodID methodID, ...);
CallStaticByteMethodV, // jbyte JNICALL CallStaticByteMethodV(jclass clazz, jmethodID methodID, va_list args);
0, // jbyte JNICALL CallStaticByteMethodA(jclass clazz, jmethodID methodID, jvalue *args);
CallStaticCharMethod, // jchar JNICALL CallStaticCharMethod(jclass clazz, jmethodID methodID, ...);
CallStaticCharMethodV, // jchar JNICALL CallStaticCharMethodV(jclass clazz, jmethodID methodID, va_list args);
0, // jchar JNICALL CallStaticCharMethodA(jclass clazz, jmethodID methodID, jvalue *args);
CallStaticShortMethod, // jshort JNICALL CallStaticShortMethod(jclass clazz, jmethodID methodID, ...);
CallStaticShortMethodV, // jshort JNICALL CallStaticShortMethodV(jclass clazz, jmethodID methodID, va_list args);
0, // jshort JNICALL CallStaticShortMethodA(jclass clazz, jmethodID methodID, jvalue *args);
CallStaticIntMethod, // jint JNICALL CallStaticIntMethod(jclass clazz, jmethodID methodID, ...);
CallStaticIntMethodV, // jint JNICALL CallStaticIntMethodV(jclass clazz, jmethodID methodID, va_list args);
0, // jint JNICALL CallStaticIntMethodA(jclass clazz, jmethodID methodID, jvalue *args);
CallStaticLongMethod, // jlong JNICALL CallStaticLongMethod(jclass clazz, jmethodID methodID, ...);
CallStaticLongMethodV, // jlong JNICALL CallStaticLongMethodV(jclass clazz, jmethodID methodID, va_list args);
0, // jlong JNICALL CallStaticLongMethodA(jclass clazz, jmethodID methodID, jvalue *args);
CallStaticFloatMethod, // jfloat JNICALL CallStaticFloatMethod(jclass clazz, jmethodID methodID, ...);
CallStaticFloatMethodV, // jfloat JNICALL CallStaticFloatMethodV(jclass clazz, jmethodID methodID, va_list args);
0, // jfloat JNICALL CallStaticFloatMethodA(jclass clazz, jmethodID methodID, jvalue *args);
CallStaticDoubleMethod, // jdouble JNICALL CallStaticDoubleMethod(jclass clazz, jmethodID methodID, ...);
CallStaticDoubleMethodV, // jdouble JNICALL CallStaticDoubleMethodV(jclass clazz, jmethodID methodID, va_list args);
0, // jdouble JNICALL CallStaticDoubleMethodA(jclass clazz, jmethodID methodID, jvalue *args);
CallStaticVoidMethod, // void JNICALL CallStaticVoidMethod(jclass cls, jmethodID methodID, ...);
CallStaticVoidMethodV, // void JNICALL CallStaticVoidMethodV(jclass cls, jmethodID methodID, va_list args);
0, // void JNICALL CallStaticVoidMethodA(jclass cls, jmethodID methodID, jvalue * args);
0, // jfieldID JNICALL GetStaticFieldID(jclass clazz, const char *name, const char *sig);
0, // jobject JNICALL GetObjectField(jobject obj, jfieldID fieldID);
0, // jboolean JNICALL GetBooleanField(jobject obj, jfieldID fieldID);
0, // jbyte JNICALL GetByteField(jobject obj, jfieldID fieldID);
0, // jchar JNICALL GetCharField(jobject obj, jfieldID fieldID);
0, // jshort JNICALL GetShortField(jobject obj, jfieldID fieldID);
0, // jint JNICALL GetIntField(jobject obj, jfieldID fieldID);
0, // jlong JNICALL GetLongField(jobject obj, jfieldID fieldID);
0, // jfloat JNICALL GetFloatField(jobject obj, jfieldID fieldID);
0, // jdouble JNICALL GetDoubleField(jobject obj, jfieldID fieldID);
0, // void JNICALL SetObjectField(jobject obj, jfieldID fieldID, jobject val);
0, // void JNICALL SetBooleanField(jobject obj, jfieldID fieldID, jboolean val);
0, // void JNICALL SetByteField(jobject obj, jfieldID fieldID, jbyte val);
0, // void JNICALL SetCharField(jobject obj, jfieldID fieldID, jchar val);
0, // void JNICALL SetShortField(jobject obj, jfieldID fieldID, jshort val);
0, // void JNICALL SetIntField(jobject obj, jfieldID fieldID, jint val);
0, // void JNICALL SetLongField(jobject obj, jfieldID fieldID, jlong val);
0, // void JNICALL SetFloatField(jobject obj, jfieldID fieldID, jfloat val);
0, // void JNICALL SetDoubleField(jobject obj, jfieldID fieldID, jdouble val);
0, // jstring JNICALL NewString(const jchar *unicode, jsize len);
0, // jsize JNICALL GetStringLength(jstring str);
0, // const jchar *JNICALL GetStringChars(jstring str, jboolean *isCopy);
0, // void JNICALL ReleaseStringChars(jstring str, const jchar *chars);
0, // jstring JNICALL NewStringUTF(const char *utf);
0, // jsize JNICALL GetStringUTFLength(jstring str);
0, // const char* JNICALL GetStringUTFChars(jstring str, jboolean *isCopy);
0, // void JNICALL ReleaseStringUTFChars(jstring str, const char* chars);
0, // jsize JNICALL GetArrayLength(jarray array);
0, // jobjectArray JNICALL NewObjectArray(jsize len, jclass clazz, jobject init);
0, // jobject JNICALL GetObjectArrayElement(jobjectArray array, jsize index);
0, // void JNICALL SetObjectArrayElement(jobjectArray array, jsize index, jobject val);
0, // jbooleanArray JNICALL NewBooleanArray(jsize len);
0, // jbyteArray JNICALL NewByteArray(jsize len);
0, // jcharArray JNICALL NewCharArray(jsize len);
0, // jshortArray JNICALL NewShortArray(jsize len);
0, // jintArray JNICALL NewIntArray(jsize len);
0, // jlongArray JNICALL NewLongArray(jsize len);
0, // jfloatArray JNICALL NewFloatArray(jsize len);
0, // jdoubleArray JNICALL NewDoubleArray(jsize len);
0, // jboolean * JNICALL GetBooleanArrayElements(jbooleanArray array, jboolean *isCopy);
0, // jbyte * JNICALL GetByteArrayElements(jbyteArray array, jboolean *isCopy);
0, // jchar * JNICALL GetCharArrayElements(jcharArray array, jboolean *isCopy);
0, // jshort * JNICALL GetShortArrayElements(jshortArray array, jboolean *isCopy);
0, // jint * JNICALL GetIntArrayElements(jintArray array, jboolean *isCopy);
0, // jlong * JNICALL GetLongArrayElements(jlongArray array, jboolean *isCopy);
0, // jfloat * JNICALL GetFloatArrayElements(jfloatArray array, jboolean *isCopy);
0, // jdouble * JNICALL GetDoubleArrayElements(jdoubleArray array, jboolean *isCopy);
0, // void JNICALL ReleaseBooleanArrayElements(jbooleanArray array, jboolean *elems, jint mode);
0, // void JNICALL ReleaseByteArrayElements(jbyteArray array, jbyte *elems, jint mode);
0, // void JNICALL ReleaseCharArrayElements(jcharArray array, jchar *elems, jint mode);
0, // void JNICALL ReleaseShortArrayElements(jshortArray array, jshort *elems, jint mode);
0, // void JNICALL ReleaseIntArrayElements(jintArray array, jint *elems, jint mode);
0, // void JNICALL ReleaseLongArrayElements(jlongArray array, jlong *elems, jint mode);
0, // void JNICALL ReleaseFloatArrayElements(jfloatArray array, jfloat *elems, jint mode);
0, // void JNICALL ReleaseDoubleArrayElements(jdoubleArray array, jdouble *elems, jint mode);
0, // void JNICALL GetBooleanArrayRegion(jbooleanArray array, jsize start, jsize l, jboolean *buf);
0, // void JNICALL GetByteArrayRegion(jbyteArray array, jsize start, jsize len, jbyte *buf);
0, // void JNICALL GetCharArrayRegion(jcharArray array, jsize start, jsize len, jchar *buf);
0, // void JNICALL GetShortArrayRegion(jshortArray array, jsize start, jsize len, jshort *buf);
0, // void JNICALL GetIntArrayRegion(jintArray array, jsize start, jsize len, jint *buf);
0, // void JNICALL GetLongArrayRegion(jlongArray array, jsize start, jsize len, jlong *buf);
0, // void JNICALL GetFloatArrayRegion(jfloatArray array, jsize start, jsize len, jfloat *buf);
0, // void JNICALL GetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, jdouble *buf);
0, // void JNICALL SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize l, jboolean *buf);
0, // void JNICALL SetByteArrayRegion(jbyteArray array, jsize start, jsize len, jbyte *buf);
0, // void JNICALL SetCharArrayRegion(jcharArray array, jsize start, jsize len, jchar *buf);
0, // void JNICALL SetShortArrayRegion(jshortArray array, jsize start, jsize len, jshort *buf);
0, // void JNICALL SetIntArrayRegion(jintArray array, jsize start, jsize len, jint *buf);
0, // void JNICALL SetLongArrayRegion(jlongArray array, jsize start, jsize len, jlong *buf);
0, // void JNICALL SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, jfloat *buf);
0, // void JNICALL SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, jdouble *buf);
0, // jint JNICALL RegisterNatives(jclass clazz, const JNINativeMethod *methods, jint nMethods);
0, // jint JNICALL UnregisterNatives(jclass clazz);
0, // jint JNICALL MonitorEnter(jobject obj);
0, // jint JNICALL MonitorExit(jobject obj);
0, // jint JNICALL GetJavaVM(JavaVM **vm);
0, // void JNICALL GetStringRegion(jstring str, jsize start, jsize len, jchar *buf);
0, // void JNICALL GetStringUTFRegion(jstring str, jsize start, jsize len, char *buf);
0, // void* JNICALL GetPrimitiveArrayCritical(jarray array, jboolean *isCopy);
0, // void JNICALL ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode);
0, // const jchar* JNICALL GetStringCritical(jstring string, jboolean *isCopy);
0, // void JNICALL ReleaseStringCritical(jstring string, const jchar *cstring);
0, // jweak JNICALL NewWeakGlobalRef(jobject obj);
0, // void JNICALL DeleteWeakGlobalRef(jweak ref);
0, // jboolean JNICALL ExceptionCheck();
0, // jobject JNICALL NewDirectByteBuffer(void* address, jlong capacity);
0, // void* JNICALL GetDirectBufferAddress(jobject buf);
0 // jlong JNICALL GetDirectBufferCapacity(jobject buf);
};
JNIEXPORT void** JNICALL ikvm_GetJNIEnvVTable()
{
return JNIEnv_vtable;
}
JNIEXPORT void* JNICALL ikvm_MarshalDelegate(void* p)
{
return p;
}
typedef jint (JNICALL *PJNI_ONLOAD)(JavaVM* vm, void* reserved);
JNIEXPORT jint JNICALL ikvm_CallOnLoad(PJNI_ONLOAD method, JavaVM* vm, void* reserved)
{
return method(vm, reserved);
}

401
native/jni.h Normal file
Просмотреть файл

@ -0,0 +1,401 @@
/*
Copyright (C) 2004 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
#ifndef __JNI_H__
#define __JNI_H__
#ifdef _WIN32
#define JNICALL __stdcall
#ifdef __cplusplus
#define JNIEXPORT extern "C" __declspec(dllexport)
#else
#define JNIEXPORT __declspec(dllexport)
#endif
#else
#define JNICALL
#ifdef __cplusplus
#define JNIEXPORT extern "C"
#else
#define JNIEXPORT
#endif
#include <stdarg.h>
#endif
typedef void* jobject;
typedef void* jstring;
typedef void* jweak;
typedef void* jthrowable;
typedef void* jclass;
typedef void* jmethodID;
typedef void* jfieldID;
typedef void* jarray;
typedef void* jobjectArray;
typedef void* jbooleanArray;
typedef void* jbyteArray;
typedef void* jcharArray;
typedef void* jshortArray;
typedef void* jintArray;
typedef void* jlongArray;
typedef void* jfloatArray;
typedef void* jdoubleArray;
typedef unsigned char jboolean;
typedef signed char jbyte;
typedef unsigned short jchar;
typedef short jshort;
typedef int jint;
#ifdef __GNUC__
typedef long long int jlong;
#else
typedef __int64 jlong;
#endif
typedef float jfloat;
typedef double jdouble;
typedef jint jsize;
typedef struct
{
char *name;
char *signature;
void *fnPtr;
} JNINativeMethod;
typedef union jvalue
{
jboolean z;
jbyte b;
jchar c;
jshort s;
jint i;
jlong j;
jfloat f;
jdouble d;
jobject l;
} jvalue;
typedef void* JavaVM;
typedef struct JNIEnv_methods *JNIEnv;
struct JNIEnv_methods
{
jint (JNICALL *GetMethodArgs)(JNIEnv* pEnv, jmethodID method, jbyte* sig);
void (JNICALL *reserved1)(JNIEnv* pEnv);
void (JNICALL *reserved2)(JNIEnv* pEnv);
void (JNICALL *reserved3)(JNIEnv* pEnv);
jint (JNICALL *GetVersion)(JNIEnv* pEnv);
jclass (JNICALL *DefineClass)(JNIEnv* pEnv, const char *name, jobject loader, const jbyte *buf, jsize len);
jclass (JNICALL *FindClass)(JNIEnv* pEnv, const char *name);
jmethodID (JNICALL *FromReflectedMethod)(JNIEnv* pEnv, jobject method);
jfieldID (JNICALL *FromReflectedField)(JNIEnv* pEnv, jobject field);
jobject (JNICALL *ToReflectedMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID);
jclass (JNICALL *GetSuperclass)(JNIEnv* pEnv, jclass sub);
jboolean (JNICALL *IsAssignableFrom)(JNIEnv* pEnv, jclass sub, jclass sup);
jobject (JNICALL *ToReflectedField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
jint (JNICALL *Throw)(JNIEnv* pEnv, jthrowable obj);
jint (JNICALL *ThrowNew)(JNIEnv* pEnv, jclass clazz, const char *msg);
jthrowable (JNICALL *ExceptionOccurred)(JNIEnv* pEnv);
void (JNICALL *ExceptionDescribe)(JNIEnv* pEnv);
void (JNICALL *ExceptionClear)(JNIEnv* pEnv);
void (JNICALL *FatalError)(JNIEnv* pEnv, const char *msg);
jint (JNICALL *PushLocalFrame)(JNIEnv* pEnv, jint capacity);
jobject (JNICALL *PopLocalFrame)(JNIEnv* pEnv, jobject result);
jobject (JNICALL *NewGlobalRef)(JNIEnv* pEnv, jobject lobj);
void (JNICALL *DeleteGlobalRef)(JNIEnv* pEnv, jobject gref);
void (JNICALL *DeleteLocalRef)(JNIEnv* pEnv, jobject obj);
jboolean (JNICALL *IsSameObject)(JNIEnv* pEnv, jobject obj1, jobject obj2);
jobject (JNICALL *NewLocalRef)(JNIEnv* pEnv, jobject ref);
jint (JNICALL *EnsureLocalCapacity)(JNIEnv* pEnv, jint capacity);
jobject (JNICALL *AllocObject)(JNIEnv* pEnv, jclass clazz);
jobject (JNICALL *NewObject)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...);
jobject (JNICALL *NewObjectV)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args);
jobject (JNICALL *NewObjectA)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jvalue *args);
jclass (JNICALL *GetObjectClass)(JNIEnv* pEnv, jobject obj);
jboolean (JNICALL *IsInstanceOf)(JNIEnv* pEnv, jobject obj, jclass clazz);
jmethodID (JNICALL *GetMethodID)(JNIEnv* pEnv, jclass clazz, const char *name, const char *sig);
jobject (JNICALL *CallObjectMethod)(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...);
jobject (JNICALL *CallObjectMethodV)(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args);
jobject (JNICALL *CallObjectMethodA)(JNIEnv* pEnv, jobject obj, jmethodID methodID, jvalue * args);
jboolean (JNICALL *CallBooleanMethod)(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...);
jboolean (JNICALL *CallBooleanMethodV)(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args);
jboolean (JNICALL *CallBooleanMethodA)(JNIEnv* pEnv, jobject obj, jmethodID methodID, jvalue * args);
jbyte (JNICALL *CallByteMethod)(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...);
jbyte (JNICALL *CallByteMethodV)(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args);
jbyte (JNICALL *CallByteMethodA)(JNIEnv* pEnv, jobject obj, jmethodID methodID, jvalue *args);
jchar (JNICALL *CallCharMethod)(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...);
jchar (JNICALL *CallCharMethodV)(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args);
jchar (JNICALL *CallCharMethodA)(JNIEnv* pEnv, jobject obj, jmethodID methodID, jvalue *args);
jshort (JNICALL *CallShortMethod)(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...);
jshort (JNICALL *CallShortMethodV)(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args);
jshort (JNICALL *CallShortMethodA)(JNIEnv* pEnv, jobject obj, jmethodID methodID, jvalue *args);
jint (JNICALL *CallIntMethod)(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...);
jint (JNICALL *CallIntMethodV)(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args);
jint (JNICALL *CallIntMethodA)(JNIEnv* pEnv, jobject obj, jmethodID methodID, jvalue *args);
jlong (JNICALL *CallLongMethod)(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...);
jlong (JNICALL *CallLongMethodV)(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args);
jlong (JNICALL *CallLongMethodA)(JNIEnv* pEnv, jobject obj, jmethodID methodID, jvalue *args);
jfloat (JNICALL *CallFloatMethod)(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...);
jfloat (JNICALL *CallFloatMethodV)(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args);
jfloat (JNICALL *CallFloatMethodA)(JNIEnv* pEnv, jobject obj, jmethodID methodID, jvalue *args);
jdouble (JNICALL *CallDoubleMethod)(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...);
jdouble (JNICALL *CallDoubleMethodV)(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args);
jdouble (JNICALL *CallDoubleMethodA)(JNIEnv* pEnv, jobject obj, jmethodID methodID, jvalue *args);
void (JNICALL *CallVoidMethod)(JNIEnv* pEnv, jobject obj, jmethodID methodID, ...);
void (JNICALL *CallVoidMethodV)(JNIEnv* pEnv, jobject obj, jmethodID methodID, va_list args);
void (JNICALL *CallVoidMethodA)(JNIEnv* pEnv, jobject obj, jmethodID methodID, jvalue * args);
jobject (JNICALL *CallNonvirtualObjectMethod)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...);
jobject (JNICALL *CallNonvirtualObjectMethodV)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args);
jobject (JNICALL *CallNonvirtualObjectMethodA)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
jboolean (JNICALL *CallNonvirtualBooleanMethod)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...);
jboolean (JNICALL *CallNonvirtualBooleanMethodV)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args);
jboolean (JNICALL *CallNonvirtualBooleanMethodA)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
jbyte (JNICALL *CallNonvirtualByteMethod)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...);
jbyte (JNICALL *CallNonvirtualByteMethodV)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args);
jbyte (JNICALL *CallNonvirtualByteMethodA)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
jchar (JNICALL *CallNonvirtualCharMethod)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...);
jchar (JNICALL *CallNonvirtualCharMethodV)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args);
jchar (JNICALL *CallNonvirtualCharMethodA)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
jshort (JNICALL *CallNonvirtualShortMethod)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...);
jshort (JNICALL *CallNonvirtualShortMethodV)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args);
jshort (JNICALL *CallNonvirtualShortMethodA)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
jint (JNICALL *CallNonvirtualIntMethod)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...);
jint (JNICALL *CallNonvirtualIntMethodV)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args);
jint (JNICALL *CallNonvirtualIntMethodA)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
jlong (JNICALL *CallNonvirtualLongMethod)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...);
jlong (JNICALL *CallNonvirtualLongMethodV)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args);
jlong (JNICALL *CallNonvirtualLongMethodA)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
jfloat (JNICALL *CallNonvirtualFloatMethod)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...);
jfloat (JNICALL *CallNonvirtualFloatMethodV)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args);
jfloat (JNICALL *CallNonvirtualFloatMethodA)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
jdouble (JNICALL *CallNonvirtualDoubleMethod)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...);
jdouble (JNICALL *CallNonvirtualDoubleMethodV)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args);
jdouble (JNICALL *CallNonvirtualDoubleMethodA)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, jvalue *args);
void (JNICALL *CallNonvirtualVoidMethod)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, ...);
void (JNICALL *CallNonvirtualVoidMethodV)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, va_list args);
void (JNICALL *CallNonvirtualVoidMethodA)(JNIEnv* pEnv, jobject obj, jclass clazz, jmethodID methodID, jvalue * args);
jfieldID (JNICALL *GetFieldID)(JNIEnv* pEnv, jclass clazz, const char *name, const char *sig);
jobject (JNICALL *GetObjectField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID);
jboolean (JNICALL *GetBooleanField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID);
jbyte (JNICALL *GetByteField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID);
jchar (JNICALL *GetCharField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID);
jshort (JNICALL *GetShortField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID);
jint (JNICALL *GetIntField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID);
jlong (JNICALL *GetLongField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID);
jfloat (JNICALL *GetFloatField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID);
jdouble (JNICALL *GetDoubleField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID);
void (JNICALL *SetObjectField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID, jobject val);
void (JNICALL *SetBooleanField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID, jboolean val);
void (JNICALL *SetByteField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID, jbyte val);
void (JNICALL *SetCharField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID, jchar val);
void (JNICALL *SetShortField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID, jshort val);
void (JNICALL *SetIntField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID, jint val);
void (JNICALL *SetLongField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID, jlong val);
void (JNICALL *SetFloatField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID, jfloat val);
void (JNICALL *SetDoubleField)(JNIEnv* pEnv, jobject obj, jfieldID fieldID, jdouble val);
jmethodID (JNICALL *GetStaticMethodID)(JNIEnv* pEnv, jclass clazz, const char *name, const char *sig);
jobject (JNICALL *CallStaticObjectMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...);
jobject (JNICALL *CallStaticObjectMethodV)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args);
jobject (JNICALL *CallStaticObjectMethodA)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jvalue *args);
jboolean (JNICALL *CallStaticBooleanMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...);
jboolean (JNICALL *CallStaticBooleanMethodV)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args);
jboolean (JNICALL *CallStaticBooleanMethodA)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jvalue *args);
jbyte (JNICALL *CallStaticByteMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...);
jbyte (JNICALL *CallStaticByteMethodV)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args);
jbyte (JNICALL *CallStaticByteMethodA)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jvalue *args);
jchar (JNICALL *CallStaticCharMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...);
jchar (JNICALL *CallStaticCharMethodV)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args);
jchar (JNICALL *CallStaticCharMethodA)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jvalue *args);
jshort (JNICALL *CallStaticShortMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...);
jshort (JNICALL *CallStaticShortMethodV)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args);
jshort (JNICALL *CallStaticShortMethodA)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jvalue *args);
jint (JNICALL *CallStaticIntMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...);
jint (JNICALL *CallStaticIntMethodV)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args);
jint (JNICALL *CallStaticIntMethodA)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jvalue *args);
jlong (JNICALL *CallStaticLongMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...);
jlong (JNICALL *CallStaticLongMethodV)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args);
jlong (JNICALL *CallStaticLongMethodA)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jvalue *args);
jfloat (JNICALL *CallStaticFloatMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...);
jfloat (JNICALL *CallStaticFloatMethodV)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args);
jfloat (JNICALL *CallStaticFloatMethodA)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jvalue *args);
jdouble (JNICALL *CallStaticDoubleMethod)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, ...);
jdouble (JNICALL *CallStaticDoubleMethodV)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, va_list args);
jdouble (JNICALL *CallStaticDoubleMethodA)(JNIEnv* pEnv, jclass clazz, jmethodID methodID, jvalue *args);
void (JNICALL *CallStaticVoidMethod)(JNIEnv* pEnv, jclass cls, jmethodID methodID, ...);
void (JNICALL *CallStaticVoidMethodV)(JNIEnv* pEnv, jclass cls, jmethodID methodID, va_list args);
void (JNICALL *CallStaticVoidMethodA)(JNIEnv* pEnv, jclass cls, jmethodID methodID, jvalue * args);
jfieldID (JNICALL *GetStaticFieldID)(JNIEnv* pEnv, jclass clazz, const char *name, const char *sig);
jobject (JNICALL *GetStaticObjectField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
jboolean (JNICALL *GetStaticBooleanField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
jbyte (JNICALL *GetStaticByteField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
jchar (JNICALL *GetStaticCharField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
jshort (JNICALL *GetStaticShortField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
jint (JNICALL *GetStaticIntField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
jlong (JNICALL *GetStaticLongField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
jfloat (JNICALL *GetStaticFloatField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
jdouble (JNICALL *GetStaticDoubleField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID);
void (JNICALL *SetStaticObjectField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID, jobject value);
void (JNICALL *SetStaticBooleanField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID, jboolean value);
void (JNICALL *SetStaticByteField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID, jbyte value);
void (JNICALL *SetStaticCharField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID, jchar value);
void (JNICALL *SetStaticShortField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID, jshort value);
void (JNICALL *SetStaticIntField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID, jint value);
void (JNICALL *SetStaticLongField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID, jlong value);
void (JNICALL *SetStaticFloatField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID, jfloat value);
void (JNICALL *SetStaticDoubleField)(JNIEnv* pEnv, jclass clazz, jfieldID fieldID, jdouble value);
jstring (JNICALL *NewString)(JNIEnv* pEnv, const jchar *unicode, jsize len);
jsize (JNICALL *GetStringLength)(JNIEnv* pEnv, jstring str);
const jchar *(JNICALL *GetStringChars)(JNIEnv* pEnv, jstring str, jboolean *isCopy);
void (JNICALL *ReleaseStringChars)(JNIEnv* pEnv, jstring str, const jchar *chars);
jstring (JNICALL *NewStringUTF)(JNIEnv* pEnv, const char *utf);
jsize (JNICALL *GetStringUTFLength)(JNIEnv* pEnv, jstring str);
const char* (JNICALL *GetStringUTFChars)(JNIEnv* pEnv, jstring str, jboolean *isCopy);
void (JNICALL *ReleaseStringUTFChars)(JNIEnv* pEnv, jstring str, const char* chars);
jsize (JNICALL *GetArrayLength)(JNIEnv* pEnv, jarray array);
jobjectArray (JNICALL *NewObjectArray)(JNIEnv* pEnv, jsize len, jclass clazz, jobject init);
jobject (JNICALL *GetObjectArrayElement)(JNIEnv* pEnv, jobjectArray array, jsize index);
void (JNICALL *SetObjectArrayElement)(JNIEnv* pEnv, jobjectArray array, jsize index, jobject val);
jbooleanArray (JNICALL *NewBooleanArray)(JNIEnv* pEnv, jsize len);
jbyteArray (JNICALL *NewByteArray)(JNIEnv* pEnv, jsize len);
jcharArray (JNICALL *NewCharArray)(JNIEnv* pEnv, jsize len);
jshortArray (JNICALL *NewShortArray)(JNIEnv* pEnv, jsize len);
jintArray (JNICALL *NewIntArray)(JNIEnv* pEnv, jsize len);
jlongArray (JNICALL *NewLongArray)(JNIEnv* pEnv, jsize len);
jfloatArray (JNICALL *NewFloatArray)(JNIEnv* pEnv, jsize len);
jdoubleArray (JNICALL *NewDoubleArray)(JNIEnv* pEnv, jsize len);
jboolean * (JNICALL *GetBooleanArrayElements)(JNIEnv* pEnv, jbooleanArray array, jboolean *isCopy);
jbyte * (JNICALL *GetByteArrayElements)(JNIEnv* pEnv, jbyteArray array, jboolean *isCopy);
jchar * (JNICALL *GetCharArrayElements)(JNIEnv* pEnv, jcharArray array, jboolean *isCopy);
jshort * (JNICALL *GetShortArrayElements)(JNIEnv* pEnv, jshortArray array, jboolean *isCopy);
jint * (JNICALL *GetIntArrayElements)(JNIEnv* pEnv, jintArray array, jboolean *isCopy);
jlong * (JNICALL *GetLongArrayElements)(JNIEnv* pEnv, jlongArray array, jboolean *isCopy);
jfloat * (JNICALL *GetFloatArrayElements)(JNIEnv* pEnv, jfloatArray array, jboolean *isCopy);
jdouble * (JNICALL *GetDoubleArrayElements)(JNIEnv* pEnv, jdoubleArray array, jboolean *isCopy);
void (JNICALL *ReleaseBooleanArrayElements)(JNIEnv* pEnv, jbooleanArray array, jboolean *elems, jint mode);
void (JNICALL *ReleaseByteArrayElements)(JNIEnv* pEnv, jbyteArray array, jbyte *elems, jint mode);
void (JNICALL *ReleaseCharArrayElements)(JNIEnv* pEnv, jcharArray array, jchar *elems, jint mode);
void (JNICALL *ReleaseShortArrayElements)(JNIEnv* pEnv, jshortArray array, jshort *elems, jint mode);
void (JNICALL *ReleaseIntArrayElements)(JNIEnv* pEnv, jintArray array, jint *elems, jint mode);
void (JNICALL *ReleaseLongArrayElements)(JNIEnv* pEnv, jlongArray array, jlong *elems, jint mode);
void (JNICALL *ReleaseFloatArrayElements)(JNIEnv* pEnv, jfloatArray array, jfloat *elems, jint mode);
void (JNICALL *ReleaseDoubleArrayElements)(JNIEnv* pEnv, jdoubleArray array, jdouble *elems, jint mode);
void (JNICALL *GetBooleanArrayRegion)(JNIEnv* pEnv, jbooleanArray array, jsize start, jsize l, jboolean *buf);
void (JNICALL *GetByteArrayRegion)(JNIEnv* pEnv, jbyteArray array, jsize start, jsize len, jbyte *buf);
void (JNICALL *GetCharArrayRegion)(JNIEnv* pEnv, jcharArray array, jsize start, jsize len, jchar *buf);
void (JNICALL *GetShortArrayRegion)(JNIEnv* pEnv, jshortArray array, jsize start, jsize len, jshort *buf);
void (JNICALL *GetIntArrayRegion)(JNIEnv* pEnv, jintArray array, jsize start, jsize len, jint *buf);
void (JNICALL *GetLongArrayRegion)(JNIEnv* pEnv, jlongArray array, jsize start, jsize len, jlong *buf);
void (JNICALL *GetFloatArrayRegion)(JNIEnv* pEnv, jfloatArray array, jsize start, jsize len, jfloat *buf);
void (JNICALL *GetDoubleArrayRegion)(JNIEnv* pEnv, jdoubleArray array, jsize start, jsize len, jdouble *buf);
void (JNICALL *SetBooleanArrayRegion)(JNIEnv* pEnv, jbooleanArray array, jsize start, jsize l, jboolean *buf);
void (JNICALL *SetByteArrayRegion)(JNIEnv* pEnv, jbyteArray array, jsize start, jsize len, jbyte *buf);
void (JNICALL *SetCharArrayRegion)(JNIEnv* pEnv, jcharArray array, jsize start, jsize len, jchar *buf);
void (JNICALL *SetShortArrayRegion)(JNIEnv* pEnv, jshortArray array, jsize start, jsize len, jshort *buf);
void (JNICALL *SetIntArrayRegion)(JNIEnv* pEnv, jintArray array, jsize start, jsize len, jint *buf);
void (JNICALL *SetLongArrayRegion)(JNIEnv* pEnv, jlongArray array, jsize start, jsize len, jlong *buf);
void (JNICALL *SetFloatArrayRegion)(JNIEnv* pEnv, jfloatArray array, jsize start, jsize len, jfloat *buf);
void (JNICALL *SetDoubleArrayRegion)(JNIEnv* pEnv, jdoubleArray array, jsize start, jsize len, jdouble *buf);
jint (JNICALL *RegisterNatives)(JNIEnv* pEnv, jclass clazz, const JNINativeMethod *methods, jint nMethods);
jint (JNICALL *UnregisterNatives)(JNIEnv* pEnv, jclass clazz);
jint (JNICALL *MonitorEnter)(JNIEnv* pEnv, jobject obj);
jint (JNICALL *MonitorExit)(JNIEnv* pEnv, jobject obj);
jint (JNICALL *GetJavaVM)(JNIEnv* pEnv, JavaVM **vm);
void (JNICALL *GetStringRegion)(JNIEnv* pEnv, jstring str, jsize start, jsize len, jchar *buf);
void (JNICALL *GetStringUTFRegion)(JNIEnv* pEnv, jstring str, jsize start, jsize len, char *buf);
void* (JNICALL *GetPrimitiveArrayCritical)(JNIEnv* pEnv, jarray array, jboolean *isCopy);
void (JNICALL *ReleasePrimitiveArrayCritical)(JNIEnv* pEnv, jarray array, void *carray, jint mode);
const jchar* (JNICALL *GetStringCritical)(JNIEnv* pEnv, jstring string, jboolean *isCopy);
void (JNICALL *ReleaseStringCritical)(JNIEnv* pEnv, jstring string, const jchar *cstring);
jweak (JNICALL *NewWeakGlobalRef)(JNIEnv* pEnv, jobject obj);
void (JNICALL *DeleteWeakGlobalRef)(JNIEnv* pEnv, jweak ref);
jboolean (JNICALL *ExceptionCheck)(JNIEnv* pEnv);
jobject (JNICALL *NewDirectByteBuffer)(JNIEnv* pEnv, void* address, jlong capacity);
void* (JNICALL *GetDirectBufferAddress)(JNIEnv* pEnv, jobject buf);
jlong (JNICALL *GetDirectBufferCapacity)(JNIEnv* pEnv, jobject buf);
};
#endif //__JNI_H__

29
native/native.build Normal file
Просмотреть файл

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<project name="ikvm-native" default="ikvm-native">
<target name="ikvm-native">
<if propertytrue="nant.platform.unix">
<call target="ikvm-native-unix"/>
</if>
<if propertytrue="nant.platform.win32">
<call target="ikvm-native-win32"/>
</if>
</target>
<target name="ikvm-native-unix">
<exec program="/bin/bash" commandline="-c 'gcc -o libikvm-native.so --shared -fPIC `pkg-config --cflags gmodule-2.0` jni.c os.c'"/>
<copy file="libikvm-native.so" todir="../bin"/>
</target>
<target name="ikvm-native-win32">
<mkdir dir="Release"/>
<cl outputdir="Release" options="/O2 /D WIN32 /D NDEBUG /D _WINDLL /D _MBCS /GS /W3 /nologo /c">
<sources>
<includes name="*.c"/>
</sources>
</cl>
<link output="Release/ikvm-native.dll" options="/DLL user32.lib">
<sources>
<includes name="Release/*.obj"/>
</sources>
</link>
<copy file="Release/ikvm-native.dll" todir="../bin" />
</target>
</project>

Просмотреть файл

@ -2,9 +2,9 @@
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="7.10" Version="7.10"
Name="IKVM.JNI.CLR-Win32" Name="ikvm-native"
ProjectGUID="{4D400F9D-68A1-4066-95F6-85AF0E58B710}" ProjectGUID="{14EC8F2A-90C6-4CFC-AD26-04C9A3392B8E}"
Keyword="ManagedCProj"> Keyword="Win32Proj">
<Platforms> <Platforms>
<Platform <Platform
Name="Win32"/> Name="Win32"/>
@ -15,27 +15,29 @@
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="2" ConfigurationType="2"
CharacterSet="2" CharacterSet="2">
ManagedExtensions="TRUE">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;NATIVE_EXPORTS"
MinimalRebuild="FALSE" MinimalRebuild="TRUE"
BasicRuntimeChecks="0" BasicRuntimeChecks="3"
RuntimeLibrary="1" RuntimeLibrary="1"
TreatWChar_tAsBuiltInType="TRUE" UsePrecompiledHeader="0"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="3"
WarningLevel="3" WarningLevel="3"
DebugInformationFormat="3"/> Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(OutDir)/IKVM.JNI.CLR-Win32.dll" OutputFile="$(OutDir)/ikvm-native.dll"
LinkIncremental="2" LinkIncremental="2"
GenerateDebugInformation="TRUE"/> GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/native.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/native.lib"
TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
@ -62,26 +64,27 @@
OutputDirectory="Release" OutputDirectory="Release"
IntermediateDirectory="Release" IntermediateDirectory="Release"
ConfigurationType="2" ConfigurationType="2"
CharacterSet="2" CharacterSet="2">
ManagedExtensions="TRUE">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="2" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;NATIVE_EXPORTS"
InlineFunctionExpansion="1" RuntimeLibrary="0"
PreprocessorDefinitions="WIN32;NDEBUG" UsePrecompiledHeader="0"
MinimalRebuild="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="3"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/> DebugInformationFormat="3"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(OutDir)/IKVM.JNI.CLR-Win32.dll" OutputFile="$(OutDir)/ikvm-native.dll"
LinkIncremental="1" LinkIncremental="1"
GenerateDebugInformation="TRUE"/> GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/native.lib"
TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
@ -105,55 +108,31 @@
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
<ProjectReference
ReferencedProjectIdentifier="{F5C7B588-0403-4AF2-A4DE-5697DE21BC2C}"
Name="IKVM.Runtime"/>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"> Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File <File
RelativePath="AssemblyInfo.cpp"> RelativePath=".\jni.c">
</File> </File>
<File <File
RelativePath="jni.cpp"> RelativePath=".\os.c">
</File>
<File
RelativePath="jnienv.cpp">
</File>
<File
RelativePath="Stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc"> Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File <File
RelativePath="jni.h"> RelativePath=".\jni.h">
</File>
<File
RelativePath="jnienv.h">
</File>
<File
RelativePath="Stdafx.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Resource Files" Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;r"> Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>

73
native/os.c Normal file
Просмотреть файл

@ -0,0 +1,73 @@
/*
Copyright (C) 2004 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
jeroen@frijters.net
*/
#ifdef _WIN32
#include <windows.h>
#include "jni.h"
JNIEXPORT void* JNICALL ikvm_LoadLibrary(char* psz)
{
return LoadLibrary(psz);
}
JNIEXPORT void JNICALL ikvm_FreeLibrary(HMODULE handle)
{
FreeLibrary(handle);
}
JNIEXPORT void* JNICALL ikvm_GetProcAddress(HMODULE handle, char* name, jint argc)
{
char buf[512];
if(strlen(name) > sizeof(buf) - 11)
{
return 0;
}
wsprintf(buf, "_%s@%d", name, argc);
return GetProcAddress(handle, buf);
}
#else
#include <gmodule.h>
#include "jni.h"
JNIEXPORT void* JNICALL ikvm_LoadLibrary(char* psz)
{
return g_module_open(psz, 0);
}
JNIEXPORT void JNICALL ikvm_FreeLibrary(GModule* handle)
{
g_module_close(handle);
}
JNIEXPORT void* JNICALL ikvm_GetProcAddress(GModule* handle, char* name, jint argc)
{
void *symbol;
gboolean res = g_module_symbol(handle, name, &symbol);
if (res)
return symbol;
else
return NULL;
}
#endif

Просмотреть файл

@ -28,30 +28,26 @@ sealed class BigEndianBinaryReader
{ {
private byte[] buf; private byte[] buf;
private int pos; private int pos;
private int end;
internal BigEndianBinaryReader(byte[] buf) internal BigEndianBinaryReader(byte[] buf, int offset, int length)
: this(buf, 0)
{
}
internal BigEndianBinaryReader(byte[] buf, int offset)
{ {
this.buf = buf; this.buf = buf;
this.pos = offset; this.pos = offset;
this.end = checked(offset + length);
if(offset < 0 || length < 0 || buf.Length - offset < length)
{
throw new ClassFormatError("Truncated class file");
}
} }
internal BigEndianBinaryReader Section(int length) internal BigEndianBinaryReader Section(uint length)
{ {
BigEndianBinaryReader br = new BigEndianBinaryReader(buf, pos); BigEndianBinaryReader br = new BigEndianBinaryReader(buf, pos, checked((int)length));
pos += length; Skip(length);
return br; return br;
} }
internal BigEndianBinaryReader Duplicate()
{
return new BigEndianBinaryReader(buf, pos);
}
internal int Position internal int Position
{ {
get get
@ -60,18 +56,33 @@ sealed class BigEndianBinaryReader
} }
} }
internal void Skip(int count) internal void Skip(uint count)
{ {
pos += count; if(end - pos < count)
{
throw new ClassFormatError("Truncated class file");
}
checked
{
pos += (int)count;
}
} }
internal byte ReadByte() internal byte ReadByte()
{ {
if(pos == end)
{
throw new ClassFormatError("Truncated class file");
}
return buf[pos++]; return buf[pos++];
} }
internal sbyte ReadSByte() internal sbyte ReadSByte()
{ {
if(pos == end)
{
throw new ClassFormatError("Truncated class file");
}
return (sbyte)buf[pos++]; return (sbyte)buf[pos++];
} }
@ -82,6 +93,10 @@ sealed class BigEndianBinaryReader
internal short ReadInt16() internal short ReadInt16()
{ {
if(end - pos < 2)
{
throw new ClassFormatError("Truncated class file");
}
short s = (short)((buf[pos] << 8) + buf[pos + 1]); short s = (short)((buf[pos] << 8) + buf[pos + 1]);
pos += 2; pos += 2;
return s; return s;
@ -89,6 +104,10 @@ sealed class BigEndianBinaryReader
internal int ReadInt32() internal int ReadInt32()
{ {
if(end - pos < 4)
{
throw new ClassFormatError("Truncated class file");
}
int i = (int)((buf[pos] << 24) + (buf[pos + 1] << 16) + (buf[pos + 2] << 8) + buf[pos + 3]); int i = (int)((buf[pos] << 24) + (buf[pos + 1] << 16) + (buf[pos + 2] << 8) + buf[pos + 3]);
pos += 4; pos += 4;
return i; return i;
@ -96,6 +115,10 @@ sealed class BigEndianBinaryReader
internal long ReadInt64() internal long ReadInt64()
{ {
if(end - pos < 8)
{
throw new ClassFormatError("Truncated class file");
}
uint i1 = (uint)((buf[pos] << 24) + (buf[pos + 1] << 16) + (buf[pos + 2] << 8) + buf[pos + 3]); uint i1 = (uint)((buf[pos] << 24) + (buf[pos + 1] << 16) + (buf[pos + 2] << 8) + buf[pos + 3]);
uint i2 = (uint)((buf[pos + 4] << 24) + (buf[pos + 5] << 16) + (buf[pos + 6] << 8) + buf[pos + 7]); uint i2 = (uint)((buf[pos + 4] << 24) + (buf[pos + 5] << 16) + (buf[pos + 6] << 8) + buf[pos + 7]);
long l = (((long)i1) << 32) + i2; long l = (((long)i1) << 32) + i2;
@ -111,6 +134,10 @@ sealed class BigEndianBinaryReader
internal string ReadString() internal string ReadString()
{ {
int len = ReadUInt16(); int len = ReadUInt16();
if(end - pos < len)
{
throw new ClassFormatError("Truncated class file");
}
// special code path for ASCII strings (which occur *very* frequently) // special code path for ASCII strings (which occur *very* frequently)
for(int j = 0; j < len; j++) for(int j = 0; j < len; j++)
{ {
@ -129,7 +156,7 @@ sealed class BigEndianBinaryReader
case 0: case 0:
if(c == 0) if(c == 0)
{ {
throw new FormatException(); throw new ClassFormatError("Illegal UTF8 string in constant pool");
} }
break; break;
case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
@ -140,7 +167,7 @@ sealed class BigEndianBinaryReader
char2 = buf[pos + ++i]; char2 = buf[pos + ++i];
if((char2 & 0xc0) != 0x80) if((char2 & 0xc0) != 0x80)
{ {
throw new FormatException(); throw new ClassFormatError("Illegal UTF8 string in constant pool");
} }
c = (((c & 0x1F) << 6) | (char2 & 0x3F)); c = (((c & 0x1F) << 6) | (char2 & 0x3F));
break; break;
@ -150,12 +177,12 @@ sealed class BigEndianBinaryReader
char3 = buf[pos + ++i]; char3 = buf[pos + ++i];
if((char2 & 0xc0) != 0x80 || (char3 & 0xc0) != 0x80) if((char2 & 0xc0) != 0x80 || (char3 & 0xc0) != 0x80)
{ {
throw new FormatException(); throw new ClassFormatError("Illegal UTF8 string in constant pool");
} }
c = (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)); c = (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
break; break;
default: default:
throw new FormatException(); throw new ClassFormatError("Illegal UTF8 string in constant pool");
} }
ch[l++] = (char)c; ch[l++] = (char)c;
} }
@ -170,6 +197,10 @@ sealed class BigEndianBinaryReader
internal ushort ReadUInt16() internal ushort ReadUInt16()
{ {
if(end - pos < 2)
{
throw new ClassFormatError("Truncated class file");
}
ushort s = (ushort)((buf[pos] << 8) + buf[pos + 1]); ushort s = (ushort)((buf[pos] << 8) + buf[pos + 1]);
pos += 2; pos += 2;
return s; return s;
@ -177,6 +208,10 @@ sealed class BigEndianBinaryReader
internal uint ReadUInt32() internal uint ReadUInt32()
{ {
if(end - pos < 4)
{
throw new ClassFormatError("Truncated class file");
}
uint i = (uint)((buf[pos] << 24) + (buf[pos + 1] << 16) + (buf[pos + 2] << 8) + buf[pos + 3]); uint i = (uint)((buf[pos] << 24) + (buf[pos + 1] << 16) + (buf[pos + 2] << 8) + buf[pos + 3]);
pos += 4; pos += 4;
return i; return i;

Просмотреть файл

@ -23,7 +23,7 @@
*/ */
using System; using System;
enum ByteCode enum ByteCode : byte
{ {
__nop = 0, __nop = 0,
__aconst_null = 1, __aconst_null = 1,
@ -229,11 +229,11 @@ enum ByteCode
__jsr_w = 201 __jsr_w = 201
} }
enum NormalizedByteCode enum NormalizedByteCode : byte
{ {
__nop = 0, __nop = 0,
__aconst_null = 1, __aconst_null = 1,
__iconst = -1, __iconst = 255,
__lconst_0 = 9, __lconst_0 = 9,
__lconst_1 = 10, __lconst_1 = 10,
__fconst_0 = 11, __fconst_0 = 11,
@ -380,7 +380,7 @@ enum NormalizedByteCode
__ifnonnull = 199, __ifnonnull = 199,
} }
enum ByteCodeMode enum ByteCodeMode : byte
{ {
Unused, Unused,
Simple, Simple,
@ -388,58 +388,80 @@ enum ByteCodeMode
Constant_2, Constant_2,
Branch_2, Branch_2,
Local_1, Local_1,
Local_2,
Constant_2_1_1, Constant_2_1_1,
Immediate_1, Immediate_1,
Immediate_2, Immediate_2,
Local_1_Immediate_1, Local_1_Immediate_1,
Local_2_Immediate_2,
Tableswitch, Tableswitch,
Lookupswitch, Lookupswitch,
Constant_2_Immediate_1, Constant_2_Immediate_1,
Branch_4 Branch_4,
WidePrefix
}
enum ByteCodeModeWide : byte
{
Unused,
Local_2,
Local_2_Immediate_2
}
[Flags]
enum ByteCodeFlags : byte
{
None = 0,
FixedArg = 1,
CannotThrow = 2
} }
struct ByteCodeMetaData struct ByteCodeMetaData
{ {
private static ByteCodeMetaData[] data = new ByteCodeMetaData[202]; private static ByteCodeMetaData[] data = new ByteCodeMetaData[202];
private ByteCodeMode reg; private ByteCodeMode reg;
private ByteCodeMode wide; private ByteCodeModeWide wide;
private NormalizedByteCode normbc; private NormalizedByteCode normbc;
private ByteCodeFlags flags;
private int arg; private int arg;
private bool hasFixedArg;
private bool cannotThrow;
private ByteCodeMetaData(ByteCode bc, ByteCodeMode reg, ByteCodeMode wide, bool cannotThrow) private ByteCodeMetaData(ByteCode bc, ByteCodeMode reg, ByteCodeModeWide wide, bool cannotThrow)
{ {
this.reg = reg; this.reg = reg;
this.wide = wide; this.wide = wide;
this.normbc = (NormalizedByteCode)Enum.Parse(typeof(NormalizedByteCode), bc.ToString()); this.normbc = (NormalizedByteCode)bc;
this.arg = 0; this.arg = 0;
this.hasFixedArg = false; this.flags = ByteCodeFlags.None;
this.cannotThrow = cannotThrow; if(cannotThrow)
{
this.flags |= ByteCodeFlags.CannotThrow;
}
data[(int)bc] = this; data[(int)bc] = this;
} }
private ByteCodeMetaData(ByteCode bc, NormalizedByteCode normbc, ByteCodeMode reg, ByteCodeMode wide, bool cannotThrow) private ByteCodeMetaData(ByteCode bc, NormalizedByteCode normbc, ByteCodeMode reg, ByteCodeModeWide wide, bool cannotThrow)
{ {
this.reg = reg; this.reg = reg;
this.wide = wide; this.wide = wide;
this.normbc = normbc; this.normbc = normbc;
this.arg = 0; this.arg = 0;
this.hasFixedArg = false; this.flags = ByteCodeFlags.None;
this.cannotThrow = cannotThrow; if(cannotThrow)
{
this.flags |= ByteCodeFlags.CannotThrow;
}
data[(int)bc] = this; data[(int)bc] = this;
} }
private ByteCodeMetaData(ByteCode bc, NormalizedByteCode normbc, int arg, ByteCodeMode reg, ByteCodeMode wide, bool cannotThrow) private ByteCodeMetaData(ByteCode bc, NormalizedByteCode normbc, int arg, ByteCodeMode reg, ByteCodeModeWide wide, bool cannotThrow)
{ {
this.reg = reg; this.reg = reg;
this.wide = wide; this.wide = wide;
this.normbc = normbc; this.normbc = normbc;
this.arg = arg; this.arg = arg;
this.hasFixedArg = true; this.flags = ByteCodeFlags.FixedArg;
this.cannotThrow = cannotThrow; if(cannotThrow)
{
this.flags |= ByteCodeFlags.CannotThrow;
}
data[(int)bc] = this; data[(int)bc] = this;
} }
@ -450,7 +472,7 @@ struct ByteCodeMetaData
internal static int GetArg(ByteCode bc, int arg) internal static int GetArg(ByteCode bc, int arg)
{ {
if(data[(int)bc].hasFixedArg) if((data[(int)bc].flags & ByteCodeFlags.FixedArg) != 0)
{ {
return data[(int)bc].arg; return data[(int)bc].arg;
} }
@ -462,224 +484,219 @@ struct ByteCodeMetaData
return data[(int)bc].reg; return data[(int)bc].reg;
} }
internal static ByteCodeMode GetWideMode(ByteCode bc) internal static ByteCodeModeWide GetWideMode(ByteCode bc)
{ {
ByteCodeMode m = data[(int)bc].wide; return data[(int)bc].wide;
if(m == ByteCodeMode.Unused)
{
throw new ArgumentException("Wide version of " + bc + " is not a valid instruction", "bc");
}
return m;
} }
internal static bool CanThrowException(ByteCode bc) internal static bool CanThrowException(ByteCode bc)
{ {
return !data[(int)bc].cannotThrow; return (data[(int)bc].flags & ByteCodeFlags.CannotThrow) == 0;
} }
static ByteCodeMetaData() static ByteCodeMetaData()
{ {
new ByteCodeMetaData(ByteCode.__nop, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__nop, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__aconst_null, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__aconst_null, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iconst_m1, NormalizedByteCode.__iconst, -1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iconst_m1, NormalizedByteCode.__iconst, -1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iconst_0, NormalizedByteCode.__iconst, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iconst_0, NormalizedByteCode.__iconst, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iconst_1, NormalizedByteCode.__iconst, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iconst_1, NormalizedByteCode.__iconst, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iconst_2, NormalizedByteCode.__iconst, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iconst_2, NormalizedByteCode.__iconst, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iconst_3, NormalizedByteCode.__iconst, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iconst_3, NormalizedByteCode.__iconst, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iconst_4, NormalizedByteCode.__iconst, 4, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iconst_4, NormalizedByteCode.__iconst, 4, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iconst_5, NormalizedByteCode.__iconst, 5, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iconst_5, NormalizedByteCode.__iconst, 5, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lconst_0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lconst_0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lconst_1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lconst_1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fconst_0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fconst_0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fconst_1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fconst_1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fconst_2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fconst_2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dconst_0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dconst_0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dconst_1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dconst_1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__bipush, NormalizedByteCode.__iconst, ByteCodeMode.Immediate_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__bipush, NormalizedByteCode.__iconst, ByteCodeMode.Immediate_1, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__sipush, NormalizedByteCode.__iconst, ByteCodeMode.Immediate_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__sipush, NormalizedByteCode.__iconst, ByteCodeMode.Immediate_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ldc, ByteCodeMode.Constant_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ldc, ByteCodeMode.Constant_1, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ldc_w, NormalizedByteCode.__ldc, ByteCodeMode.Constant_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ldc_w, NormalizedByteCode.__ldc, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ldc2_w, NormalizedByteCode.__ldc, ByteCodeMode.Constant_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ldc2_w, NormalizedByteCode.__ldc, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iload, ByteCodeMode.Local_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iload, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__lload, ByteCodeMode.Local_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lload, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__fload, ByteCodeMode.Local_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fload, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__dload, ByteCodeMode.Local_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dload, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__aload, ByteCodeMode.Local_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__aload, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__iload_0, NormalizedByteCode.__iload, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iload_0, NormalizedByteCode.__iload, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iload_1, NormalizedByteCode.__iload, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iload_1, NormalizedByteCode.__iload, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iload_2, NormalizedByteCode.__iload, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iload_2, NormalizedByteCode.__iload, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iload_3, NormalizedByteCode.__iload, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iload_3, NormalizedByteCode.__iload, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lload_0, NormalizedByteCode.__lload, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lload_0, NormalizedByteCode.__lload, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lload_1, NormalizedByteCode.__lload, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lload_1, NormalizedByteCode.__lload, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lload_2, NormalizedByteCode.__lload, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lload_2, NormalizedByteCode.__lload, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lload_3, NormalizedByteCode.__lload, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lload_3, NormalizedByteCode.__lload, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fload_0, NormalizedByteCode.__fload, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fload_0, NormalizedByteCode.__fload, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fload_1, NormalizedByteCode.__fload, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fload_1, NormalizedByteCode.__fload, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fload_2, NormalizedByteCode.__fload, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fload_2, NormalizedByteCode.__fload, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fload_3, NormalizedByteCode.__fload, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fload_3, NormalizedByteCode.__fload, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dload_0, NormalizedByteCode.__dload, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dload_0, NormalizedByteCode.__dload, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dload_1, NormalizedByteCode.__dload, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dload_1, NormalizedByteCode.__dload, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dload_2, NormalizedByteCode.__dload, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dload_2, NormalizedByteCode.__dload, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dload_3, NormalizedByteCode.__dload, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dload_3, NormalizedByteCode.__dload, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__aload_0, NormalizedByteCode.__aload, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__aload_0, NormalizedByteCode.__aload, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__aload_1, NormalizedByteCode.__aload, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__aload_1, NormalizedByteCode.__aload, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__aload_2, NormalizedByteCode.__aload, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__aload_2, NormalizedByteCode.__aload, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__aload_3, NormalizedByteCode.__aload, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__aload_3, NormalizedByteCode.__aload, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iaload, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__iaload, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__laload, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__laload, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__faload, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__faload, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__daload, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__daload, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__aaload, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__aaload, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__baload, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__baload, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__caload, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__caload, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__saload, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__saload, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__istore, ByteCodeMode.Local_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__istore, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__lstore, ByteCodeMode.Local_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lstore, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__fstore, ByteCodeMode.Local_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fstore, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__dstore, ByteCodeMode.Local_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dstore, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__astore, ByteCodeMode.Local_1, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__astore, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__istore_0, NormalizedByteCode.__istore, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__istore_0, NormalizedByteCode.__istore, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__istore_1, NormalizedByteCode.__istore, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__istore_1, NormalizedByteCode.__istore, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__istore_2, NormalizedByteCode.__istore, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__istore_2, NormalizedByteCode.__istore, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__istore_3, NormalizedByteCode.__istore, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__istore_3, NormalizedByteCode.__istore, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lstore_0, NormalizedByteCode.__lstore, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lstore_0, NormalizedByteCode.__lstore, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lstore_1, NormalizedByteCode.__lstore, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lstore_1, NormalizedByteCode.__lstore, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lstore_2, NormalizedByteCode.__lstore, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lstore_2, NormalizedByteCode.__lstore, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lstore_3, NormalizedByteCode.__lstore, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lstore_3, NormalizedByteCode.__lstore, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fstore_0, NormalizedByteCode.__fstore, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fstore_0, NormalizedByteCode.__fstore, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fstore_1, NormalizedByteCode.__fstore, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fstore_1, NormalizedByteCode.__fstore, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fstore_2, NormalizedByteCode.__fstore, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fstore_2, NormalizedByteCode.__fstore, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fstore_3, NormalizedByteCode.__fstore, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fstore_3, NormalizedByteCode.__fstore, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dstore_0, NormalizedByteCode.__dstore, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dstore_0, NormalizedByteCode.__dstore, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dstore_1, NormalizedByteCode.__dstore, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dstore_1, NormalizedByteCode.__dstore, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dstore_2, NormalizedByteCode.__dstore, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dstore_2, NormalizedByteCode.__dstore, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dstore_3, NormalizedByteCode.__dstore, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dstore_3, NormalizedByteCode.__dstore, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__astore_0, NormalizedByteCode.__astore, 0, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__astore_0, NormalizedByteCode.__astore, 0, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__astore_1, NormalizedByteCode.__astore, 1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__astore_1, NormalizedByteCode.__astore, 1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__astore_2, NormalizedByteCode.__astore, 2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__astore_2, NormalizedByteCode.__astore, 2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__astore_3, NormalizedByteCode.__astore, 3, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__astore_3, NormalizedByteCode.__astore, 3, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iastore, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__iastore, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__lastore, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__lastore, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__fastore, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__fastore, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__dastore, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__dastore, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__aastore, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__aastore, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__bastore, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__bastore, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__castore, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__castore, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__sastore, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__sastore, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__pop, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__pop, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__pop2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__pop2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dup, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dup, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dup_x1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dup_x1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dup_x2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dup_x2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dup2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dup2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dup2_x1, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dup2_x1, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dup2_x2, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dup2_x2, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__swap, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__swap, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iadd, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iadd, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ladd, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ladd, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fadd, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fadd, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dadd, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dadd, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__isub, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__isub, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lsub, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lsub, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fsub, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fsub, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dsub, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dsub, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__imul, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__imul, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lmul, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lmul, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fmul, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fmul, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dmul, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dmul, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__idiv, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__idiv, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ldiv, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ldiv, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fdiv, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fdiv, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ddiv, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ddiv, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__irem, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__irem, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lrem, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lrem, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__frem, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__frem, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__drem, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__drem, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ineg, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ineg, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lneg, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lneg, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fneg, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fneg, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dneg, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dneg, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ishl, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ishl, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lshl, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lshl, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ishr, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ishr, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lshr, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lshr, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iushr, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iushr, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lushr, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lushr, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iand, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iand, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__land, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__land, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ior, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ior, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lor, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lor, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ixor, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ixor, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lxor, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lxor, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iinc, ByteCodeMode.Local_1_Immediate_1, ByteCodeMode.Local_2_Immediate_2, true); new ByteCodeMetaData(ByteCode.__iinc, ByteCodeMode.Local_1_Immediate_1, ByteCodeModeWide.Local_2_Immediate_2, true);
new ByteCodeMetaData(ByteCode.__i2l, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__i2l, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__i2f, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__i2f, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__i2d, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__i2d, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__l2i, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__l2i, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__l2f, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__l2f, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__l2d, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__l2d, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__f2i, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__f2i, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__f2l, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__f2l, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__f2d, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__f2d, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__d2i, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__d2i, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__d2l, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__d2l, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__d2f, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__d2f, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__i2b, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__i2b, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__i2c, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__i2c, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__i2s, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__i2s, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lcmp, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lcmp, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fcmpl, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fcmpl, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__fcmpg, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__fcmpg, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dcmpl, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dcmpl, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dcmpg, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dcmpg, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ifeq, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ifeq, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ifne, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ifne, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__iflt, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__iflt, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ifge, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ifge, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ifgt, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ifgt, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ifle, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ifle, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__if_icmpeq, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__if_icmpeq, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__if_icmpne, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__if_icmpne, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__if_icmplt, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__if_icmplt, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__if_icmpge, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__if_icmpge, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__if_icmpgt, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__if_icmpgt, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__if_icmple, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__if_icmple, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__if_acmpeq, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__if_acmpeq, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__if_acmpne, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__if_acmpne, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__goto, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__goto, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__jsr, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__jsr, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ret, ByteCodeMode.Local_1, ByteCodeMode.Local_2, true); new ByteCodeMetaData(ByteCode.__ret, ByteCodeMode.Local_1, ByteCodeModeWide.Local_2, true);
new ByteCodeMetaData(ByteCode.__tableswitch, NormalizedByteCode.__lookupswitch, ByteCodeMode.Tableswitch, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__tableswitch, NormalizedByteCode.__lookupswitch, ByteCodeMode.Tableswitch, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lookupswitch, ByteCodeMode.Lookupswitch, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lookupswitch, ByteCodeMode.Lookupswitch, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ireturn, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ireturn, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__lreturn, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__lreturn, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__freturn, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__freturn, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__dreturn, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__dreturn, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__areturn, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__areturn, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__return, ByteCodeMode.Simple, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__return, ByteCodeMode.Simple, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__getstatic, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__getstatic, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__putstatic, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__putstatic, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__getfield, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__getfield, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__putfield, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__putfield, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__invokevirtual, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__invokevirtual, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__invokespecial, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__invokespecial, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__invokestatic, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__invokestatic, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__invokeinterface, ByteCodeMode.Constant_2_1_1, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__invokeinterface, ByteCodeMode.Constant_2_1_1, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__xxxunusedxxx, NormalizedByteCode.__nop, ByteCodeMode.Unused, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__xxxunusedxxx, NormalizedByteCode.__nop, ByteCodeMode.Unused, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__new, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__new, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__newarray, ByteCodeMode.Immediate_1, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__newarray, ByteCodeMode.Immediate_1, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__anewarray, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__anewarray, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__arraylength, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__arraylength, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__athrow, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__athrow, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__checkcast, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__checkcast, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__instanceof, ByteCodeMode.Constant_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__instanceof, ByteCodeMode.Constant_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__monitorenter, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__monitorenter, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__monitorexit, ByteCodeMode.Simple, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__monitorexit, ByteCodeMode.Simple, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__wide, NormalizedByteCode.__nop, ByteCodeMode.Unused, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__wide, NormalizedByteCode.__nop, ByteCodeMode.WidePrefix, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__multianewarray, ByteCodeMode.Constant_2_Immediate_1, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__multianewarray, ByteCodeMode.Constant_2_Immediate_1, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__ifnull, ByteCodeMode.Branch_2, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__ifnull, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__ifnonnull, ByteCodeMode.Branch_2, ByteCodeMode.Unused, false); new ByteCodeMetaData(ByteCode.__ifnonnull, ByteCodeMode.Branch_2, ByteCodeModeWide.Unused, false);
new ByteCodeMetaData(ByteCode.__goto_w, NormalizedByteCode.__goto, ByteCodeMode.Branch_4, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__goto_w, NormalizedByteCode.__goto, ByteCodeMode.Branch_4, ByteCodeModeWide.Unused, true);
new ByteCodeMetaData(ByteCode.__jsr_w, NormalizedByteCode.__jsr, ByteCodeMode.Branch_4, ByteCodeMode.Unused, true); new ByteCodeMetaData(ByteCode.__jsr_w, NormalizedByteCode.__jsr, ByteCodeMode.Branch_4, ByteCodeModeWide.Unused, true);
} }
} }

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -42,6 +42,7 @@ class ClassLoaderWrapper
private static ClassLoaderWrapper bootstrapClassLoader; private static ClassLoaderWrapper bootstrapClassLoader;
private object javaClassLoader; private object javaClassLoader;
private Hashtable types = new Hashtable(); private Hashtable types = new Hashtable();
private ArrayList nativeLibraries;
// FXBUG moduleBuilder is static, because multiple dynamic assemblies is broken (TypeResolve doesn't fire) // FXBUG moduleBuilder is static, because multiple dynamic assemblies is broken (TypeResolve doesn't fire)
// so for the time being, we share one dynamic assembly among all classloaders // so for the time being, we share one dynamic assembly among all classloaders
private static ModuleBuilder moduleBuilder; private static ModuleBuilder moduleBuilder;
@ -193,7 +194,7 @@ class ClassLoaderWrapper
{ {
Tracer.Warning(Tracer.Compiler, "Class name clash: {0}", name); Tracer.Warning(Tracer.Compiler, "Class name clash: {0}", name);
} }
return name + "\\\\" + instanceId; return name + "/" + instanceId;
} }
else else
{ {
@ -902,4 +903,28 @@ class ClassLoaderWrapper
return null; return null;
} }
} }
internal void RegisterNativeLibrary(IntPtr p)
{
lock(this)
{
if(nativeLibraries == null)
{
nativeLibraries = new ArrayList();
}
nativeLibraries.Add(p);
}
}
internal IntPtr[] GetNativeLibraries()
{
lock(this)
{
if(nativeLibraries == null)
{
return new IntPtr[0];
}
return (IntPtr[])nativeLibraries.ToArray(typeof(IntPtr));
}
}
} }

Просмотреть файл

@ -24,7 +24,7 @@
> >
<Config <Config
Name = "Debug" Name = "Debug"
AllowUnsafeBlocks = "false" AllowUnsafeBlocks = "true"
BaseAddress = "285212672" BaseAddress = "285212672"
CheckForOverflowUnderflow = "false" CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = "" ConfigurationOverrideFile = ""

Просмотреть файл

@ -303,4 +303,14 @@ sealed class JavaException
{ {
return (Exception)Activator.CreateInstance(Load("java.lang.InstantiationError"), new object[] { String.Format(s, args) }); return (Exception)Activator.CreateInstance(Load("java.lang.InstantiationError"), new object[] { String.Format(s, args) });
} }
internal static Exception InterruptedException()
{
return (Exception)Activator.CreateInstance(Load("java.lang.InterruptedException"));
}
internal static Exception IllegalMonitorStateException()
{
return (Exception)Activator.CreateInstance(Load("java.lang.IllegalMonitorStateException"));
}
} }

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1135,6 +1135,7 @@ class FieldWrapper : MemberWrapper
// HACK if linking fails, we unlink to make sure // HACK if linking fails, we unlink to make sure
// that the next link attempt will fail again // that the next link attempt will fail again
fieldType = null; fieldType = null;
throw;
} }
} }
} }

Просмотреть файл

@ -102,7 +102,7 @@ class EmitHelper
// have a <clinit> now, a newer version that does have a <clinit> will not have it's <clinit> called by us. // have a <clinit> now, a newer version that does have a <clinit> will not have it's <clinit> called by us.
// A possible solution would be to use RuntimeHelpers.RunClassConstructor when "type" is a Java type and // A possible solution would be to use RuntimeHelpers.RunClassConstructor when "type" is a Java type and
// lives in another assembly as the caller (which we don't know at the moment). // lives in another assembly as the caller (which we don't know at the moment).
FieldInfo field = type.GetField("__<clinit>"); FieldInfo field = type.GetField("__<clinit>", BindingFlags.Static | BindingFlags.NonPublic);
if(field != null) if(field != null)
{ {
ilgen.Emit(OpCodes.Ldsfld, field); ilgen.Emit(OpCodes.Ldsfld, field);
@ -676,10 +676,6 @@ abstract class TypeWrapper
protected abstract FieldWrapper GetFieldImpl(string fieldName, TypeWrapper fieldType); protected abstract FieldWrapper GetFieldImpl(string fieldName, TypeWrapper fieldType);
// internal FieldWrapper GetFieldWrapper(string fieldName, string fieldSig)
// {
// }
internal virtual FieldWrapper GetFieldWrapper(string fieldName, TypeWrapper fieldType) internal virtual FieldWrapper GetFieldWrapper(string fieldName, TypeWrapper fieldType)
{ {
lock(fields.SyncRoot) lock(fields.SyncRoot)
@ -1385,9 +1381,7 @@ abstract class TypeWrapper
{ {
ilgen.Emit(OpCodes.Isinst, TypeAsTBD); ilgen.Emit(OpCodes.Isinst, TypeAsTBD);
ilgen.Emit(OpCodes.Ldnull); ilgen.Emit(OpCodes.Ldnull);
ilgen.Emit(OpCodes.Ceq); ilgen.Emit(OpCodes.Cgt_Un);
ilgen.Emit(OpCodes.Ldc_I4_0);
ilgen.Emit(OpCodes.Ceq);
} }
} }
@ -2013,6 +2007,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
private readonly TypeWrapper outerClassWrapper; private readonly TypeWrapper outerClassWrapper;
private readonly TypeBuilder typeBuilderGhostInterface; private readonly TypeBuilder typeBuilderGhostInterface;
private Hashtable memberclashtable; private Hashtable memberclashtable;
private Hashtable classCache = new Hashtable();
internal JavaTypeImpl(ClassFile f, DynamicTypeWrapper wrapper) internal JavaTypeImpl(ClassFile f, DynamicTypeWrapper wrapper)
{ {
@ -2376,7 +2371,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
// make sure all classes are loaded, before we start finishing the type. During finishing, we // make sure all classes are loaded, before we start finishing the type. During finishing, we
// may not run any Java code, because that might result in a request to finish the type that we // may not run any Java code, because that might result in a request to finish the type that we
// are in the process of finishing, and this would be a problem. // are in the process of finishing, and this would be a problem.
classFile.Link(wrapper); classFile.Link(wrapper, classCache);
// for(int i = 0; i < fields.Length; i++) // for(int i = 0; i < fields.Length; i++)
// { // {
// fields[i].Link(); // fields[i].Link();
@ -2408,13 +2403,13 @@ sealed class DynamicTypeWrapper : TypeWrapper
{ {
if(innerclasses[i].innerClass != 0 && innerclasses[i].outerClass != 0) if(innerclasses[i].innerClass != 0 && innerclasses[i].outerClass != 0)
{ {
if(classFile.GetConstantPoolClassType(innerclasses[i].outerClass, wrapper.GetClassLoader()) == wrapper) if(classFile.GetConstantPoolClassType(innerclasses[i].outerClass) == wrapper)
{ {
wrappers.Add(classFile.GetConstantPoolClassType(innerclasses[i].innerClass, wrapper.GetClassLoader())); wrappers.Add(classFile.GetConstantPoolClassType(innerclasses[i].innerClass));
} }
if(classFile.GetConstantPoolClassType(innerclasses[i].innerClass, wrapper.GetClassLoader()) == wrapper) if(classFile.GetConstantPoolClassType(innerclasses[i].innerClass) == wrapper)
{ {
declaringTypeWrapper = classFile.GetConstantPoolClassType(innerclasses[i].outerClass, wrapper.GetClassLoader()); declaringTypeWrapper = classFile.GetConstantPoolClassType(innerclasses[i].outerClass);
AttributeHelper.SetInnerClass(typeBuilder, AttributeHelper.SetInnerClass(typeBuilder,
classFile.GetConstantPoolClass(innerclasses[i].innerClass), classFile.GetConstantPoolClass(innerclasses[i].innerClass),
classFile.GetConstantPoolClass(innerclasses[i].outerClass), classFile.GetConstantPoolClass(innerclasses[i].outerClass),
@ -2532,9 +2527,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
ilgen.Emit(OpCodes.Ldarg_0); ilgen.Emit(OpCodes.Ldarg_0);
ilgen.Emit(OpCodes.Isinst, wrapper.TypeAsBaseType); ilgen.Emit(OpCodes.Isinst, wrapper.TypeAsBaseType);
ilgen.Emit(OpCodes.Ldnull); ilgen.Emit(OpCodes.Ldnull);
ilgen.Emit(OpCodes.Ceq); ilgen.Emit(OpCodes.Cgt_Un);
ilgen.Emit(OpCodes.Ldc_I4_0);
ilgen.Emit(OpCodes.Ceq);
ilgen.MarkLabel(end); ilgen.MarkLabel(end);
ilgen.Emit(OpCodes.Ret); ilgen.Emit(OpCodes.Ret);
// Implement the "IsInstanceArray" method // Implement the "IsInstanceArray" method
@ -2673,7 +2666,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
if(mb is ConstructorBuilder) if(mb is ConstructorBuilder)
{ {
ILGenerator ilGenerator = ((ConstructorBuilder)mb).GetILGenerator(); ILGenerator ilGenerator = ((ConstructorBuilder)mb).GetILGenerator();
Tracer.EmitMethodTrace(ilGenerator, m.ClassFile.Name + "." + m.Name + m.Signature); Tracer.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
if(basehasclinit && m.IsClassInitializer && !classFile.IsInterface) if(basehasclinit && m.IsClassInitializer && !classFile.IsInterface)
{ {
hasclinit = true; hasclinit = true;
@ -2681,7 +2674,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
EmitConstantValueInitialization(ilGenerator); EmitConstantValueInitialization(ilGenerator);
EmitHelper.RunClassConstructor(ilGenerator, Type.BaseType); EmitHelper.RunClassConstructor(ilGenerator, Type.BaseType);
} }
Compiler.Compile(wrapper, m, ilGenerator); Compiler.Compile(wrapper, methods[i], classFile, m, ilGenerator);
} }
else else
{ {
@ -2689,11 +2682,11 @@ sealed class DynamicTypeWrapper : TypeWrapper
{ {
// NOTE in the JVM it is apparently legal for a non-abstract class to have abstract methods, but // NOTE in the JVM it is apparently legal for a non-abstract class to have abstract methods, but
// the CLR doens't allow this, so we have to emit a method that throws an AbstractMethodError // the CLR doens't allow this, so we have to emit a method that throws an AbstractMethodError
if(!m.ClassFile.IsAbstract && !m.ClassFile.IsInterface) if(!classFile.IsAbstract && !classFile.IsInterface)
{ {
ILGenerator ilGenerator = ((MethodBuilder)mb).GetILGenerator(); ILGenerator ilGenerator = ((MethodBuilder)mb).GetILGenerator();
Tracer.EmitMethodTrace(ilGenerator, m.ClassFile.Name + "." + m.Name + m.Signature); Tracer.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
EmitHelper.Throw(ilGenerator, "java.lang.AbstractMethodError", m.ClassFile.Name + "." + m.Name + m.Signature); EmitHelper.Throw(ilGenerator, "java.lang.AbstractMethodError", classFile.Name + "." + m.Name + m.Signature);
} }
} }
else if(m.IsNative) else if(m.IsNative)
@ -2702,7 +2695,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
try try
{ {
ILGenerator ilGenerator = ((MethodBuilder)mb).GetILGenerator(); ILGenerator ilGenerator = ((MethodBuilder)mb).GetILGenerator();
Tracer.EmitMethodTrace(ilGenerator, m.ClassFile.Name + "." + m.Name + m.Signature); Tracer.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
// do we have a native implementation in map.xml? // do we have a native implementation in map.xml?
if(nativeMethods != null) if(nativeMethods != null)
{ {
@ -2716,7 +2709,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
// see if there exists a NativeCode class for this type // see if there exists a NativeCode class for this type
Type nativeCodeType = Type.GetType("NativeCode." + classFile.Name.Replace('$', '+')); Type nativeCodeType = Type.GetType("NativeCode." + classFile.Name.Replace('$', '+'));
MethodInfo nativeMethod = null; MethodInfo nativeMethod = null;
TypeWrapper[] args = m.GetArgTypes(wrapper.GetClassLoader()); TypeWrapper[] args = methods[i].GetParameters();
if(nativeCodeType != null) if(nativeCodeType != null)
{ {
TypeWrapper[] nargs = args; TypeWrapper[] nargs = args;
@ -2775,11 +2768,11 @@ sealed class DynamicTypeWrapper : TypeWrapper
{ {
if(ClassLoaderWrapper.IsSaveDebugImage) if(ClassLoaderWrapper.IsSaveDebugImage)
{ {
JniProxyBuilder.Generate(ilGenerator, wrapper, typeBuilder, m, args); JniProxyBuilder.Generate(ilGenerator, wrapper, methods[i], typeBuilder, classFile, m, args);
} }
else else
{ {
JniBuilder.Generate(ilGenerator, wrapper, typeBuilder, m, args); JniBuilder.Generate(ilGenerator, wrapper, methods[i], typeBuilder, classFile, m, args);
} }
} }
} }
@ -2792,8 +2785,8 @@ sealed class DynamicTypeWrapper : TypeWrapper
else else
{ {
ILGenerator ilGenerator = ((MethodBuilder)mb).GetILGenerator(); ILGenerator ilGenerator = ((MethodBuilder)mb).GetILGenerator();
Tracer.EmitMethodTrace(ilGenerator, m.ClassFile.Name + "." + m.Name + m.Signature); Tracer.EmitMethodTrace(ilGenerator, classFile.Name + "." + m.Name + m.Signature);
Compiler.Compile(wrapper, m, ilGenerator); Compiler.Compile(wrapper, methods[i], classFile, m, ilGenerator);
} }
} }
} }
@ -2935,7 +2928,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
return n; return n;
} }
internal static void Generate(ILGenerator ilGenerator, TypeWrapper wrapper, TypeBuilder typeBuilder, ClassFile.Method m, TypeWrapper[] args) internal static void Generate(ILGenerator ilGenerator, TypeWrapper wrapper, MethodWrapper mw, TypeBuilder typeBuilder, ClassFile classFile, ClassFile.Method m, TypeWrapper[] args)
{ {
if(mod == null) if(mod == null)
{ {
@ -2952,8 +2945,8 @@ sealed class DynamicTypeWrapper : TypeWrapper
{ {
argTypes[i] = args[i].TypeAsParameterType; argTypes[i] = args[i].TypeAsParameterType;
} }
MethodBuilder mb = tb.DefineMethod("method", MethodAttributes.Public | MethodAttributes.Static, m.GetRetType(wrapper.GetClassLoader()).TypeAsParameterType, argTypes); MethodBuilder mb = tb.DefineMethod("method", MethodAttributes.Public | MethodAttributes.Static, mw.ReturnType.TypeAsParameterType, argTypes);
JniBuilder.Generate(mb.GetILGenerator(), wrapper, tb, m, args); JniBuilder.Generate(mb.GetILGenerator(), wrapper, mw, tb, classFile, m, args);
for(int i = 0; i < argTypes.Length; i++) for(int i = 0; i < argTypes.Length; i++)
{ {
ilGenerator.Emit(OpCodes.Ldarg, (short)i); ilGenerator.Emit(OpCodes.Ldarg, (short)i);
@ -2971,8 +2964,8 @@ sealed class DynamicTypeWrapper : TypeWrapper
private class JniBuilder private class JniBuilder
{ {
private static readonly Type localRefStructType = JVM.JniProvider.GetLocalRefStructType(); private static readonly Type localRefStructType = typeof(JniFrame);
private static readonly MethodInfo jniFuncPtrMethod = JVM.JniProvider.GetJniFuncPtrMethod(); private static readonly MethodInfo jniFuncPtrMethod = localRefStructType.GetMethod("GetFuncPtr");
private static readonly MethodInfo enterLocalRefStruct = localRefStructType.GetMethod("Enter"); private static readonly MethodInfo enterLocalRefStruct = localRefStructType.GetMethod("Enter");
private static readonly MethodInfo leaveLocalRefStruct = localRefStructType.GetMethod("Leave"); private static readonly MethodInfo leaveLocalRefStruct = localRefStructType.GetMethod("Leave");
private static readonly MethodInfo makeLocalRef = localRefStructType.GetMethod("MakeLocalRef"); private static readonly MethodInfo makeLocalRef = localRefStructType.GetMethod("MakeLocalRef");
@ -2981,27 +2974,29 @@ sealed class DynamicTypeWrapper : TypeWrapper
private static readonly MethodInfo getClassFromType = typeof(NativeCode.java.lang.VMClass).GetMethod("getClassFromType"); private static readonly MethodInfo getClassFromType = typeof(NativeCode.java.lang.VMClass).GetMethod("getClassFromType");
private static readonly MethodInfo writeLine = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(object) }, null); private static readonly MethodInfo writeLine = typeof(Console).GetMethod("WriteLine", new Type[] { typeof(object) }, null);
internal static void Generate(ILGenerator ilGenerator, TypeWrapper wrapper, TypeBuilder typeBuilder, ClassFile.Method m, TypeWrapper[] args) internal static void Generate(ILGenerator ilGenerator, TypeWrapper wrapper, MethodWrapper mw, TypeBuilder typeBuilder, ClassFile classFile, ClassFile.Method m, TypeWrapper[] args)
{ {
FieldBuilder methodPtr = typeBuilder.DefineField(m.Name + "$Ptr", typeof(IntPtr), FieldAttributes.Static | FieldAttributes.PrivateScope); FieldBuilder methodPtr = typeBuilder.DefineField("jniptr/" + m.Name + m.Signature, typeof(IntPtr), FieldAttributes.Static | FieldAttributes.PrivateScope);
LocalBuilder localRefStruct = ilGenerator.DeclareLocal(localRefStructType); LocalBuilder localRefStruct = ilGenerator.DeclareLocal(localRefStructType);
ilGenerator.Emit(OpCodes.Ldloca, localRefStruct); ilGenerator.Emit(OpCodes.Ldloca, localRefStruct);
ilGenerator.Emit(OpCodes.Initobj, localRefStructType); ilGenerator.Emit(OpCodes.Initobj, localRefStructType);
ilGenerator.Emit(OpCodes.Ldsfld, methodPtr); ilGenerator.Emit(OpCodes.Ldsfld, methodPtr);
Label oklabel = ilGenerator.DefineLabel(); Label oklabel = ilGenerator.DefineLabel();
ilGenerator.Emit(OpCodes.Brtrue, oklabel); ilGenerator.Emit(OpCodes.Brtrue, oklabel);
ilGenerator.Emit(OpCodes.Ldtoken, (MethodInfo)mw.GetMethod());
ilGenerator.Emit(OpCodes.Ldstr, classFile.Name.Replace('.', '/'));
ilGenerator.Emit(OpCodes.Ldstr, m.Name); ilGenerator.Emit(OpCodes.Ldstr, m.Name);
ilGenerator.Emit(OpCodes.Ldstr, m.Signature.Replace('.', '/')); ilGenerator.Emit(OpCodes.Ldstr, m.Signature.Replace('.', '/'));
ilGenerator.Emit(OpCodes.Ldstr, m.ClassFile.Name.Replace('.', '/'));
ilGenerator.Emit(OpCodes.Call, jniFuncPtrMethod); ilGenerator.Emit(OpCodes.Call, jniFuncPtrMethod);
ilGenerator.Emit(OpCodes.Stsfld, methodPtr); ilGenerator.Emit(OpCodes.Stsfld, methodPtr);
ilGenerator.MarkLabel(oklabel); ilGenerator.MarkLabel(oklabel);
ilGenerator.Emit(OpCodes.Ldloca, localRefStruct); ilGenerator.Emit(OpCodes.Ldloca, localRefStruct);
ilGenerator.Emit(OpCodes.Ldtoken, (MethodInfo)mw.GetMethod());
ilGenerator.Emit(OpCodes.Call, enterLocalRefStruct); ilGenerator.Emit(OpCodes.Call, enterLocalRefStruct);
LocalBuilder jnienv = ilGenerator.DeclareLocal(typeof(IntPtr)); LocalBuilder jnienv = ilGenerator.DeclareLocal(typeof(IntPtr));
ilGenerator.Emit(OpCodes.Stloc, jnienv); ilGenerator.Emit(OpCodes.Stloc, jnienv);
Label tryBlock = ilGenerator.BeginExceptionBlock(); Label tryBlock = ilGenerator.BeginExceptionBlock();
TypeWrapper retTypeWrapper = m.GetRetType(wrapper.GetClassLoader()); TypeWrapper retTypeWrapper = mw.ReturnType;
if(!retTypeWrapper.IsPrimitive) if(!retTypeWrapper.IsPrimitive)
{ {
// this one is for use after we return from "calli" // this one is for use after we return from "calli"
@ -3188,7 +3183,8 @@ sealed class DynamicTypeWrapper : TypeWrapper
FieldBuilder field; FieldBuilder field;
ClassFile.Field fld = classFile.Fields[i]; ClassFile.Field fld = classFile.Fields[i];
string fieldName = fld.Name; string fieldName = fld.Name;
TypeWrapper typeWrapper = fld.GetFieldType(wrapper.GetClassLoader()); // TODO we're not allowed to load types here (potentially), it needs to be done in the Link step
TypeWrapper typeWrapper = ClassFile.FieldTypeWrapperFromSig(wrapper.GetClassLoader(), classCache, fld.Signature);
Type type = typeWrapper.TypeAsFieldType; Type type = typeWrapper.TypeAsFieldType;
bool setNameSig = typeWrapper.IsUnloadable || typeWrapper.IsGhostArray; bool setNameSig = typeWrapper.IsUnloadable || typeWrapper.IsGhostArray;
if(setNameSig) if(setNameSig)
@ -3236,7 +3232,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
attribs |= FieldAttributes.Literal; attribs |= FieldAttributes.Literal;
field = typeBuilder.DefineField(fieldName, type, attribs); field = typeBuilder.DefineField(fieldName, type, attribs);
field.SetConstant(constantValue); field.SetConstant(constantValue);
fields[i] = new FieldWrapper.ConstantFieldWrapper(wrapper, fld.GetFieldType(wrapper.GetClassLoader()), fld.Name, fld.Signature, fld.Modifiers, field, constantValue); fields[i] = new FieldWrapper.ConstantFieldWrapper(wrapper, typeWrapper, fld.Name, fld.Signature, fld.Modifiers, field, constantValue);
} }
else else
{ {
@ -3244,7 +3240,8 @@ sealed class DynamicTypeWrapper : TypeWrapper
if(isWrappedFinal) if(isWrappedFinal)
{ {
// NOTE public/protected blank final fields get converted into a read-only property with a private field // NOTE public/protected blank final fields get converted into a read-only property with a private field
// backing store we used to make the field privatescope, but that really serves no purpose (and it hinders // backing store
// we used to make the field privatescope, but that really serves no purpose (and it hinders
// serialization, which uses .NET reflection to get at the field) // serialization, which uses .NET reflection to get at the field)
attribs &= ~FieldAttributes.FieldAccessMask; attribs &= ~FieldAttributes.FieldAccessMask;
attribs |= FieldAttributes.Private; attribs |= FieldAttributes.Private;
@ -3302,11 +3299,11 @@ sealed class DynamicTypeWrapper : TypeWrapper
{ {
emitSet += CodeEmitter.Create(OpCodes.Stfld, field); emitSet += CodeEmitter.Create(OpCodes.Stfld, field);
} }
fields[i] = FieldWrapper.Create1(wrapper, fld.GetFieldType(wrapper.GetClassLoader()), fld.Name, fld.Signature, fld.Modifiers, field, emitGet, emitSet); fields[i] = FieldWrapper.Create1(wrapper, typeWrapper, fld.Name, fld.Signature, fld.Modifiers, field, emitGet, emitSet);
} }
else else
{ {
fields[i] = FieldWrapper.Create3(wrapper, fld.GetFieldType(wrapper.GetClassLoader()), field, fld.Signature, fld.Modifiers); fields[i] = FieldWrapper.Create3(wrapper, typeWrapper, field, fld.Signature, fld.Modifiers);
} }
} }
// if the Java modifiers cannot be expressed in .NET, we emit the Modifiers attribute to store // if the Java modifiers cannot be expressed in .NET, we emit the Modifiers attribute to store
@ -3337,7 +3334,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
{ {
// We create a field that the derived classes can access in their .cctor to trigger our .cctor // We create a field that the derived classes can access in their .cctor to trigger our .cctor
// (previously we used RuntimeHelpers.RunClassConstructor, but that is slow and requires additional privileges) // (previously we used RuntimeHelpers.RunClassConstructor, but that is slow and requires additional privileges)
FieldBuilder field = typeBuilder.DefineField("__<clinit>", typeof(int), FieldAttributes.SpecialName | FieldAttributes.Public | FieldAttributes.Static); FieldBuilder field = typeBuilder.DefineField("__<clinit>", typeof(int), FieldAttributes.SpecialName | FieldAttributes.Family | FieldAttributes.Static);
AttributeHelper.HideFromJava(field); AttributeHelper.HideFromJava(field);
} }
if(typeBuilder.IsInterface) if(typeBuilder.IsInterface)
@ -3500,7 +3497,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
// only if the classfile is abstract, we make the CLR method abstract, otherwise, // only if the classfile is abstract, we make the CLR method abstract, otherwise,
// we have to generate a method that throws an AbstractMethodError (because the JVM // we have to generate a method that throws an AbstractMethodError (because the JVM
// allows abstract methods in non-abstract classes) // allows abstract methods in non-abstract classes)
if(m.ClassFile.IsAbstract || m.ClassFile.IsInterface) if(classFile.IsAbstract || classFile.IsInterface)
{ {
attribs |= MethodAttributes.Abstract; attribs |= MethodAttributes.Abstract;
} }
@ -3685,9 +3682,7 @@ sealed class DynamicTypeWrapper : TypeWrapper
private static ParameterBuilder[] AddParameterNames(MethodBase mb, ClassFile.Method m) private static ParameterBuilder[] AddParameterNames(MethodBase mb, ClassFile.Method m)
{ {
if(m.CodeAttribute != null) ClassFile.Method.LocalVariableTableEntry[] localVars = m.LocalVariableTableAttribute;
{
ClassFile.Method.LocalVariableTableEntry[] localVars = m.CodeAttribute.LocalVariableTableAttribute;
if(localVars != null) if(localVars != null)
{ {
int bias = 1; int bias = 1;
@ -3695,10 +3690,10 @@ sealed class DynamicTypeWrapper : TypeWrapper
{ {
bias = 0; bias = 0;
} }
ParameterBuilder[] parameterBuilders = new ParameterBuilder[m.CodeAttribute.ArgMap.Length - bias]; ParameterBuilder[] parameterBuilders = new ParameterBuilder[m.ArgMap.Length - bias];
for(int i = bias; i < m.CodeAttribute.ArgMap.Length; i++) for(int i = bias; i < m.ArgMap.Length; i++)
{ {
if(m.CodeAttribute.ArgMap[i] != -1) if(m.ArgMap[i] != -1)
{ {
for(int j = 0; j < localVars.Length; j++) for(int j = 0; j < localVars.Length; j++)
{ {
@ -3706,11 +3701,11 @@ sealed class DynamicTypeWrapper : TypeWrapper
{ {
if(mb is MethodBuilder) if(mb is MethodBuilder)
{ {
parameterBuilders[i - bias] = ((MethodBuilder)mb).DefineParameter(m.CodeAttribute.ArgMap[i] + 1 - bias, ParameterAttributes.None, localVars[j].name); parameterBuilders[i - bias] = ((MethodBuilder)mb).DefineParameter(m.ArgMap[i] + 1 - bias, ParameterAttributes.None, localVars[j].name);
} }
else if(mb is ConstructorBuilder) else if(mb is ConstructorBuilder)
{ {
parameterBuilders[i - bias] = ((ConstructorBuilder)mb).DefineParameter(m.CodeAttribute.ArgMap[i], ParameterAttributes.None, localVars[j].name); parameterBuilders[i - bias] = ((ConstructorBuilder)mb).DefineParameter(m.ArgMap[i], ParameterAttributes.None, localVars[j].name);
} }
break; break;
} }
@ -3719,7 +3714,6 @@ sealed class DynamicTypeWrapper : TypeWrapper
} }
return parameterBuilders; return parameterBuilders;
} }
}
return null; return null;
} }

Просмотреть файл

@ -409,8 +409,7 @@ namespace NativeCode.java
public static int nativeLoad(string filename) public static int nativeLoad(string filename)
{ {
// TODO native libraries somehow need to be scoped by class loader return JniHelper.LoadLibrary(filename);
return JVM.JniProvider.LoadNativeLibrary(filename);
} }
} }
@ -532,7 +531,7 @@ namespace NativeCode.java
try try
{ {
// TODO I doubt that this is correct // TODO I doubt that this is correct
return double.Parse(s); return double.Parse(s, System.Globalization.CultureInfo.InvariantCulture);
} }
catch(FormatException x) catch(FormatException x)
{ {
@ -788,21 +787,11 @@ namespace NativeCode.java
} }
} }
public static bool isWordsBigEndian()
{
return !BitConverter.IsLittleEndian;
}
public static long currentTimeMillis()
{
const long january_1st_1970 = 62135596800000L;
return DateTime.UtcNow.Ticks / 10000L - january_1st_1970;
}
public static void setErr(object printStream) public static void setErr(object printStream)
{ {
TypeWrapper tw = ClassLoaderWrapper.LoadClassCritical("java.lang.System"); TypeWrapper tw = ClassLoaderWrapper.LoadClassCritical("java.lang.System");
FieldWrapper fw = tw.GetFieldWrapper("err", ClassLoaderWrapper.LoadClassCritical("java.io.PrintStream")); FieldWrapper fw = tw.GetFieldWrapper("err", ClassLoaderWrapper.LoadClassCritical("java.io.PrintStream"));
fw.SetValue(null, printStream);
} }
public static void setIn(object inputStream) public static void setIn(object inputStream)
@ -818,11 +807,6 @@ namespace NativeCode.java
FieldWrapper fw = tw.GetFieldWrapper("out", ClassLoaderWrapper.LoadClassCritical("java.io.PrintStream")); FieldWrapper fw = tw.GetFieldWrapper("out", ClassLoaderWrapper.LoadClassCritical("java.io.PrintStream"));
fw.SetValue(null, printStream); fw.SetValue(null, printStream);
} }
public static int identityHashCode(object o)
{
return RuntimeHelpers.GetHashCode(o);
}
} }
public class VMClassLoader public class VMClassLoader
@ -914,7 +898,7 @@ namespace NativeCode.java
{ {
try try
{ {
ClassFile classFile = new ClassFile(data, offset, length, name); ClassFile classFile = new ClassFile(data, offset, length, name, false);
if(name != null && classFile.Name != name) if(name != null && classFile.Name != name)
{ {
throw new NoClassDefFoundError(name + " (wrong name: " + classFile.Name + ")"); throw new NoClassDefFoundError(name + " (wrong name: " + classFile.Name + ")");
@ -1511,7 +1495,28 @@ namespace NativeCode.java
int hours = timeSpan.Hours; int hours = timeSpan.Hours;
int mins = timeSpan.Minutes; int mins = timeSpan.Minutes;
return "GMT" + hours + ":" + mins; if(mins != 0)
{
if(hours < 0)
{
return "GMT+" + ((-hours) * 60 + mins);
}
else
{
return "GMT-" + (hours * 60 + mins);
}
}
else
{
if(hours < 0)
{
return "GMT+" + (-hours);
}
else
{
return "GMT-" + (hours + mins);
}
}
} }
} }
} }

Просмотреть файл

@ -56,7 +56,9 @@ class Compiler
private static TypeWrapper java_lang_Throwable; private static TypeWrapper java_lang_Throwable;
private static TypeWrapper java_lang_ThreadDeath; private static TypeWrapper java_lang_ThreadDeath;
private TypeWrapper clazz; private TypeWrapper clazz;
private ClassFile.Method.Code m; private MethodWrapper mw;
private ClassFile classFile;
private ClassFile.Method m;
private ILGenerator ilGenerator; private ILGenerator ilGenerator;
private ClassLoaderWrapper classLoader; private ClassLoaderWrapper classLoader;
private MethodAnalyzer ma; private MethodAnalyzer ma;
@ -122,9 +124,11 @@ class Compiler
} }
} }
private Compiler(TypeWrapper clazz, ClassFile.Method.Code m, ILGenerator ilGenerator, ClassLoaderWrapper classLoader, ISymbolDocumentWriter symboldocument) private Compiler(TypeWrapper clazz, MethodWrapper mw, ClassFile classFile, ClassFile.Method m, ILGenerator ilGenerator, ClassLoaderWrapper classLoader, ISymbolDocumentWriter symboldocument)
{ {
this.clazz = clazz; this.clazz = clazz;
this.mw = mw;
this.classFile = classFile;
this.m = m; this.m = m;
this.ilGenerator = ilGenerator; this.ilGenerator = ilGenerator;
this.classLoader = classLoader; this.classLoader = classLoader;
@ -133,14 +137,14 @@ class Compiler
Profiler.Enter("MethodAnalyzer"); Profiler.Enter("MethodAnalyzer");
try try
{ {
ma = new MethodAnalyzer(clazz, m, classLoader); ma = new MethodAnalyzer(clazz, mw, classFile, m, classLoader);
} }
finally finally
{ {
Profiler.Leave("MethodAnalyzer"); Profiler.Leave("MethodAnalyzer");
} }
TypeWrapper[] args = m.Method.GetArgTypes(classLoader); TypeWrapper[] args = mw.GetParameters();
LocalVar[] locals = ma.GetAllLocalVars(); LocalVar[] locals = ma.GetAllLocalVars();
foreach(LocalVar v in locals) foreach(LocalVar v in locals)
{ {
@ -148,7 +152,7 @@ class Compiler
{ {
int arg = m.ArgMap[v.local]; int arg = m.ArgMap[v.local];
TypeWrapper tw; TypeWrapper tw;
if(m.Method.IsStatic) if(m.IsStatic)
{ {
tw = args[arg]; tw = args[arg];
} }
@ -287,9 +291,9 @@ class Compiler
{ {
case NormalizedByteCode.__lookupswitch: case NormalizedByteCode.__lookupswitch:
// start at -1 to have an opportunity to handle the default offset // start at -1 to have an opportunity to handle the default offset
for(int k = -1; k < m.Instructions[j].Values.Length; k++) for(int k = -1; k < m.Instructions[j].SwitchEntryCount; k++)
{ {
int targetPC = m.Instructions[j].PC + (k == -1 ? m.Instructions[j].DefaultOffset : m.Instructions[j].TargetOffsets[k]); int targetPC = m.Instructions[j].PC + (k == -1 ? m.Instructions[j].DefaultOffset : m.Instructions[j].GetSwitchTargetOffset(k));
if(ei.start_pc < targetPC && targetPC < ei.end_pc) if(ei.start_pc < targetPC && targetPC < ei.end_pc)
{ {
ExceptionTableEntry en = new ExceptionTableEntry(); ExceptionTableEntry en = new ExceptionTableEntry();
@ -378,7 +382,7 @@ class Compiler
// we run finally blocks when a thread is killed. // we run finally blocks when a thread is killed.
if(ei.catch_type != 0) if(ei.catch_type != 0)
{ {
TypeWrapper exceptionType = m.Method.ClassFile.GetConstantPoolClassType(ei.catch_type, classLoader); TypeWrapper exceptionType = classFile.GetConstantPoolClassType(ei.catch_type);
if(!exceptionType.IsUnloadable && !java_lang_ThreadDeath.IsAssignableTo(exceptionType)) if(!exceptionType.IsUnloadable && !java_lang_ThreadDeath.IsAssignableTo(exceptionType))
{ {
int start = FindPcIndex(ei.start_pc); int start = FindPcIndex(ei.start_pc);
@ -457,9 +461,9 @@ class Compiler
this.type = type; this.type = type;
} }
internal void Emit(ILGenerator ilgen, ClassFile.Method m) internal void Emit(ILGenerator ilgen, ClassFile classFile, ClassFile.Method m)
{ {
Tracer.Warning(Tracer.Compiler, "{0}: {1}\n\tat {2}.{3}{4}", type.Name, Message, m.ClassFile.Name, m.Name, m.Signature); Tracer.Warning(Tracer.Compiler, "{0}: {1}\n\tat {2}.{3}{4}", type.Name, Message, classFile.Name, m.Name, m.Signature);
ilgen.Emit(OpCodes.Ldstr, Message); ilgen.Emit(OpCodes.Ldstr, Message);
MethodWrapper method = type.GetMethodWrapper(new MethodDescriptor("<init>", "(Ljava.lang.String;)V"), false); MethodWrapper method = type.GetMethodWrapper(new MethodDescriptor("<init>", "(Ljava.lang.String;)V"), false);
method.Link(); method.Link();
@ -661,13 +665,13 @@ class Compiler
} }
} }
internal static void Compile(TypeWrapper clazz, ClassFile.Method m, ILGenerator ilGenerator) internal static void Compile(TypeWrapper clazz, MethodWrapper mw, ClassFile classFile, ClassFile.Method m, ILGenerator ilGenerator)
{ {
ClassLoaderWrapper classLoader = clazz.GetClassLoader(); ClassLoaderWrapper classLoader = clazz.GetClassLoader();
ISymbolDocumentWriter symboldocument = null; ISymbolDocumentWriter symboldocument = null;
if(JVM.Debug) if(JVM.Debug)
{ {
string sourcefile = m.ClassFile.SourceFileAttribute; string sourcefile = classFile.SourceFileAttribute;
if(sourcefile != null) if(sourcefile != null)
{ {
if(JVM.SourcePath != null) if(JVM.SourcePath != null)
@ -677,7 +681,7 @@ class Compiler
symboldocument = classLoader.ModuleBuilder.DefineDocument(sourcefile, SymLanguageType.Java, Guid.Empty, SymDocumentType.Text); symboldocument = classLoader.ModuleBuilder.DefineDocument(sourcefile, SymLanguageType.Java, Guid.Empty, SymDocumentType.Text);
// the very first instruction in the method must have an associated line number, to be able // the very first instruction in the method must have an associated line number, to be able
// to step into the method in Visual Studio .NET // to step into the method in Visual Studio .NET
ClassFile.Method.LineNumberTableEntry[] table = m.CodeAttribute.LineNumberTableAttribute; ClassFile.Method.LineNumberTableEntry[] table = m.LineNumberTableAttribute;
if(table != null) if(table != null)
{ {
int firstPC = int.MaxValue; int firstPC = int.MaxValue;
@ -697,7 +701,7 @@ class Compiler
} }
} }
} }
TypeWrapper[] args= m.GetArgTypes(classLoader); TypeWrapper[] args = mw.GetParameters();
for(int i = 0; i < args.Length; i++) for(int i = 0; i < args.Length; i++)
{ {
if(args[i].IsUnloadable) if(args[i].IsUnloadable)
@ -716,7 +720,7 @@ class Compiler
Profiler.Enter("new Compiler"); Profiler.Enter("new Compiler");
try try
{ {
c = new Compiler(clazz, m.CodeAttribute, ilGenerator, classLoader, symboldocument); c = new Compiler(clazz, mw, classFile, m, ilGenerator, classLoader, symboldocument);
} }
finally finally
{ {
@ -986,7 +990,7 @@ class Compiler
private void CheckLoaderConstraints(ClassFile.ConstantPoolItemFieldref cpi, FieldWrapper fw) private void CheckLoaderConstraints(ClassFile.ConstantPoolItemFieldref cpi, FieldWrapper fw)
{ {
if(cpi.GetFieldType(classLoader) != fw.FieldTypeWrapper && !fw.FieldTypeWrapper.IsUnloadable) if(cpi.GetFieldType() != fw.FieldTypeWrapper && !fw.FieldTypeWrapper.IsUnloadable)
{ {
throw new LinkageError("Loader constraints violated: " + fw.Name); throw new LinkageError("Loader constraints violated: " + fw.Name);
} }
@ -994,11 +998,11 @@ class Compiler
private void CheckLoaderConstraints(ClassFile.ConstantPoolItemMI cpi, MethodWrapper mw) private void CheckLoaderConstraints(ClassFile.ConstantPoolItemMI cpi, MethodWrapper mw)
{ {
if(cpi.GetRetType(classLoader) != mw.ReturnType && !mw.ReturnType.IsUnloadable) if(cpi.GetRetType() != mw.ReturnType && !mw.ReturnType.IsUnloadable)
{ {
throw new LinkageError("Loader constraints violated: " + mw.Name + mw.Signature); throw new LinkageError("Loader constraints violated: " + mw.Name + mw.Signature);
} }
TypeWrapper[] here = cpi.GetArgTypes(classLoader); TypeWrapper[] here = cpi.GetArgTypes();
TypeWrapper[] there = mw.GetParameters(); TypeWrapper[] there = mw.GetParameters();
for(int i = 0; i < here.Length; i++) for(int i = 0; i < here.Length; i++)
{ {
@ -1091,7 +1095,7 @@ class Compiler
} }
else else
{ {
exceptionTypeWrapper = m.Method.ClassFile.GetConstantPoolClassType(exc.catch_type, classLoader); exceptionTypeWrapper = classFile.GetConstantPoolClassType(exc.catch_type);
} }
Type excType = exceptionTypeWrapper.TypeAsExceptionType; Type excType = exceptionTypeWrapper.TypeAsExceptionType;
bool mapSafe = !exceptionTypeWrapper.IsUnloadable && !exceptionTypeWrapper.IsMapUnsafeException; bool mapSafe = !exceptionTypeWrapper.IsUnloadable && !exceptionTypeWrapper.IsMapUnsafeException;
@ -1299,28 +1303,27 @@ class Compiler
break; break;
case NormalizedByteCode.__ldc: case NormalizedByteCode.__ldc:
{ {
ClassFile cf = instr.MethodCode.Method.ClassFile;
int constant = instr.Arg1; int constant = instr.Arg1;
switch(cf.GetConstantPoolConstantType(constant)) switch(classFile.GetConstantPoolConstantType(constant))
{ {
case ClassFile.ConstantType.Double: case ClassFile.ConstantType.Double:
ilGenerator.Emit(OpCodes.Ldc_R8, cf.GetConstantPoolConstantDouble(constant)); ilGenerator.Emit(OpCodes.Ldc_R8, classFile.GetConstantPoolConstantDouble(constant));
break; break;
case ClassFile.ConstantType.Float: case ClassFile.ConstantType.Float:
ilGenerator.Emit(OpCodes.Ldc_R4, cf.GetConstantPoolConstantFloat(constant)); ilGenerator.Emit(OpCodes.Ldc_R4, classFile.GetConstantPoolConstantFloat(constant));
break; break;
case ClassFile.ConstantType.Integer: case ClassFile.ConstantType.Integer:
EmitLdc_I4(cf.GetConstantPoolConstantInteger(constant)); EmitLdc_I4(classFile.GetConstantPoolConstantInteger(constant));
break; break;
case ClassFile.ConstantType.Long: case ClassFile.ConstantType.Long:
ilGenerator.Emit(OpCodes.Ldc_I8, cf.GetConstantPoolConstantLong(constant)); ilGenerator.Emit(OpCodes.Ldc_I8, classFile.GetConstantPoolConstantLong(constant));
break; break;
case ClassFile.ConstantType.String: case ClassFile.ConstantType.String:
ilGenerator.Emit(OpCodes.Ldstr, cf.GetConstantPoolConstantString(constant)); ilGenerator.Emit(OpCodes.Ldstr, classFile.GetConstantPoolConstantString(constant));
break; break;
case ClassFile.ConstantType.Class: case ClassFile.ConstantType.Class:
{ {
TypeWrapper tw = cf.GetConstantPoolClassType(constant, classLoader); TypeWrapper tw = classFile.GetConstantPoolClassType(constant);
if(tw.IsUnloadable) if(tw.IsUnloadable)
{ {
Profiler.Count("EmitDynamicClassLiteral"); Profiler.Count("EmitDynamicClassLiteral");
@ -1344,13 +1347,13 @@ class Compiler
} }
case NormalizedByteCode.__invokestatic: case NormalizedByteCode.__invokestatic:
{ {
ClassFile.ConstantPoolItemMI cpi = m.Method.ClassFile.GetMethodref(instr.Arg1); ClassFile.ConstantPoolItemMI cpi = classFile.GetMethodref(instr.Arg1);
// HACK special case for calls to System.arraycopy, if the array arguments on the stack // HACK special case for calls to System.arraycopy, if the array arguments on the stack
// are of a known array type, we can redirect to an optimized version of arraycopy. // are of a known array type, we can redirect to an optimized version of arraycopy.
if(cpi.Class == "java.lang.System" && if(cpi.Class == "java.lang.System" &&
cpi.Name == "arraycopy" && cpi.Name == "arraycopy" &&
cpi.Signature == "(Ljava.lang.Object;ILjava.lang.Object;II)V" && cpi.Signature == "(Ljava.lang.Object;ILjava.lang.Object;II)V" &&
cpi.GetClassType(classLoader).GetClassLoader() == ClassLoaderWrapper.GetBootstrapClassLoader()) cpi.GetClassType().GetClassLoader() == ClassLoaderWrapper.GetBootstrapClassLoader())
{ {
TypeWrapper t1 = ma.GetRawStackTypeWrapper(i, 2); TypeWrapper t1 = ma.GetRawStackTypeWrapper(i, 2);
TypeWrapper t2 = ma.GetRawStackTypeWrapper(i, 4); TypeWrapper t2 = ma.GetRawStackTypeWrapper(i, 4);
@ -1384,7 +1387,7 @@ class Compiler
MethodWrapper method = GetMethodCallEmitter(cpi, null, NormalizedByteCode.__invokestatic); MethodWrapper method = GetMethodCallEmitter(cpi, null, NormalizedByteCode.__invokestatic);
// if the stack values don't match the argument types (for interface argument types) // if the stack values don't match the argument types (for interface argument types)
// we must emit code to cast the stack value to the interface type // we must emit code to cast the stack value to the interface type
CastInterfaceArgs(method, cpi.GetArgTypes(classLoader), i, false, false); CastInterfaceArgs(method, cpi.GetArgTypes(), i, false, false);
method.EmitCall(ilGenerator); method.EmitCall(ilGenerator);
break; break;
} }
@ -1392,10 +1395,10 @@ class Compiler
case NormalizedByteCode.__invokeinterface: case NormalizedByteCode.__invokeinterface:
case NormalizedByteCode.__invokespecial: case NormalizedByteCode.__invokespecial:
{ {
ClassFile.ConstantPoolItemMI cpi = m.Method.ClassFile.GetMethodref(instr.Arg1); ClassFile.ConstantPoolItemMI cpi = classFile.GetMethodref(instr.Arg1);
int argcount = cpi.GetArgTypes(classLoader).Length; int argcount = cpi.GetArgTypes().Length;
TypeWrapper type = ma.GetRawStackTypeWrapper(i, argcount); TypeWrapper type = ma.GetRawStackTypeWrapper(i, argcount);
TypeWrapper thisType = SigTypeToClassName(type, cpi.GetClassType(classLoader)); TypeWrapper thisType = SigTypeToClassName(type, cpi.GetClassType());
MethodWrapper method = GetMethodCallEmitter(cpi, thisType, instr.NormalizedOpCode); MethodWrapper method = GetMethodCallEmitter(cpi, thisType, instr.NormalizedOpCode);
@ -1403,18 +1406,18 @@ class Compiler
// we must emit code to cast the stack value to the interface type // we must emit code to cast the stack value to the interface type
if(instr.NormalizedOpCode == NormalizedByteCode.__invokespecial && cpi.Name == "<init>" && VerifierTypeWrapper.IsNew(type)) if(instr.NormalizedOpCode == NormalizedByteCode.__invokespecial && cpi.Name == "<init>" && VerifierTypeWrapper.IsNew(type))
{ {
TypeWrapper[] args = cpi.GetArgTypes(classLoader); TypeWrapper[] args = cpi.GetArgTypes();
CastInterfaceArgs(method, args, i, false, false); CastInterfaceArgs(method, args, i, false, false);
} }
else else
{ {
// the this reference is included in the argument list because it may also need to be cast // the this reference is included in the argument list because it may also need to be cast
TypeWrapper[] methodArgs = cpi.GetArgTypes(classLoader); TypeWrapper[] methodArgs = cpi.GetArgTypes();
TypeWrapper[] args = new TypeWrapper[methodArgs.Length + 1]; TypeWrapper[] args = new TypeWrapper[methodArgs.Length + 1];
methodArgs.CopyTo(args, 1); methodArgs.CopyTo(args, 1);
if(instr.NormalizedOpCode == NormalizedByteCode.__invokeinterface) if(instr.NormalizedOpCode == NormalizedByteCode.__invokeinterface)
{ {
args[0] = cpi.GetClassType(classLoader); args[0] = cpi.GetClassType();
} }
else else
{ {
@ -1586,7 +1589,7 @@ class Compiler
LocalBuilder local = null; LocalBuilder local = null;
if(instr.NormalizedOpCode != NormalizedByteCode.__return) if(instr.NormalizedOpCode != NormalizedByteCode.__return)
{ {
TypeWrapper retTypeWrapper = m.Method.GetRetType(classLoader); TypeWrapper retTypeWrapper = mw.ReturnType;
retTypeWrapper.EmitConvStackToParameterType(ilGenerator, ma.GetRawStackTypeWrapper(i, 0)); retTypeWrapper.EmitConvStackToParameterType(ilGenerator, ma.GetRawStackTypeWrapper(i, 0));
if(ma.GetRawStackTypeWrapper(i, 0).IsUnloadable) if(ma.GetRawStackTypeWrapper(i, 0).IsUnloadable)
{ {
@ -1615,7 +1618,7 @@ class Compiler
} }
else else
{ {
TypeWrapper retTypeWrapper = m.Method.GetRetType(classLoader); TypeWrapper retTypeWrapper = mw.ReturnType;
retTypeWrapper.EmitConvStackToParameterType(ilGenerator, ma.GetRawStackTypeWrapper(i, 0)); retTypeWrapper.EmitConvStackToParameterType(ilGenerator, ma.GetRawStackTypeWrapper(i, 0));
if(ma.GetRawStackTypeWrapper(i, 0).IsUnloadable) if(ma.GetRawStackTypeWrapper(i, 0).IsUnloadable)
{ {
@ -1706,7 +1709,7 @@ class Compiler
break; break;
case NormalizedByteCode.__new: case NormalizedByteCode.__new:
{ {
TypeWrapper wrapper = instr.MethodCode.Method.ClassFile.GetConstantPoolClassType(instr.Arg1, classLoader); TypeWrapper wrapper = classFile.GetConstantPoolClassType(instr.Arg1);
if(wrapper.IsUnloadable) if(wrapper.IsUnloadable)
{ {
Profiler.Count("EmitDynamicNewCheckOnly"); Profiler.Count("EmitDynamicNewCheckOnly");
@ -1742,7 +1745,7 @@ class Compiler
ilGenerator.Emit(OpCodes.Ldloc, localInt); ilGenerator.Emit(OpCodes.Ldloc, localInt);
ilGenerator.Emit(OpCodes.Stelem_I4); ilGenerator.Emit(OpCodes.Stelem_I4);
} }
TypeWrapper wrapper = instr.MethodCode.Method.ClassFile.GetConstantPoolClassType(instr.Arg1, classLoader); TypeWrapper wrapper = classFile.GetConstantPoolClassType(instr.Arg1);
if(wrapper.IsUnloadable) if(wrapper.IsUnloadable)
{ {
Profiler.Count("EmitDynamicMultianewarray"); Profiler.Count("EmitDynamicMultianewarray");
@ -1767,7 +1770,7 @@ class Compiler
} }
case NormalizedByteCode.__anewarray: case NormalizedByteCode.__anewarray:
{ {
TypeWrapper wrapper = instr.MethodCode.Method.ClassFile.GetConstantPoolClassType(instr.Arg1, classLoader); TypeWrapper wrapper = classFile.GetConstantPoolClassType(instr.Arg1);
if(wrapper.IsUnloadable) if(wrapper.IsUnloadable)
{ {
Profiler.Count("EmitDynamicNewarray"); Profiler.Count("EmitDynamicNewarray");
@ -1829,7 +1832,7 @@ class Compiler
break; break;
case NormalizedByteCode.__checkcast: case NormalizedByteCode.__checkcast:
{ {
TypeWrapper wrapper = instr.MethodCode.Method.ClassFile.GetConstantPoolClassType(instr.Arg1, classLoader); TypeWrapper wrapper = classFile.GetConstantPoolClassType(instr.Arg1);
if(!wrapper.IsUnloadable && !wrapper.IsAccessibleFrom(clazz)) if(!wrapper.IsUnloadable && !wrapper.IsAccessibleFrom(clazz))
{ {
throw new IllegalAccessError("Try to access class " + wrapper.Name + " from class " + clazz.Name); throw new IllegalAccessError("Try to access class " + wrapper.Name + " from class " + clazz.Name);
@ -1839,7 +1842,7 @@ class Compiler
} }
case NormalizedByteCode.__instanceof: case NormalizedByteCode.__instanceof:
{ {
TypeWrapper wrapper = instr.MethodCode.Method.ClassFile.GetConstantPoolClassType(instr.Arg1, classLoader); TypeWrapper wrapper = classFile.GetConstantPoolClassType(instr.Arg1);
if(!wrapper.IsUnloadable && !wrapper.IsAccessibleFrom(clazz)) if(!wrapper.IsUnloadable && !wrapper.IsAccessibleFrom(clazz))
{ {
throw new IllegalAccessError("Try to access class " + wrapper.Name + " from class " + clazz.Name); throw new IllegalAccessError("Try to access class " + wrapper.Name + " from class " + clazz.Name);
@ -2476,14 +2479,14 @@ class Compiler
break; break;
case NormalizedByteCode.__lookupswitch: case NormalizedByteCode.__lookupswitch:
// TODO use OpCodes.Switch // TODO use OpCodes.Switch
for(int j = 0; j < instr.Values.Length; j++) for(int j = 0; j < instr.SwitchEntryCount; j++)
{ {
ilGenerator.Emit(OpCodes.Dup); ilGenerator.Emit(OpCodes.Dup);
EmitLdc_I4(instr.Values[j]); EmitLdc_I4(instr.GetSwitchValue(j));
Label label = ilGenerator.DefineLabel(); Label label = ilGenerator.DefineLabel();
ilGenerator.Emit(OpCodes.Bne_Un_S, label); ilGenerator.Emit(OpCodes.Bne_Un_S, label);
ilGenerator.Emit(OpCodes.Pop); ilGenerator.Emit(OpCodes.Pop);
ilGenerator.Emit(OpCodes.Br, block.GetLabel(instr.PC + instr.TargetOffsets[j])); ilGenerator.Emit(OpCodes.Br, block.GetLabel(instr.PC + instr.GetSwitchTargetOffset(j)));
ilGenerator.MarkLabel(label); ilGenerator.MarkLabel(label);
} }
ilGenerator.Emit(OpCodes.Pop); ilGenerator.Emit(OpCodes.Pop);
@ -2598,7 +2601,7 @@ class Compiler
} }
catch(EmitException x) catch(EmitException x)
{ {
x.Emit(ilGenerator, m.Method); x.Emit(ilGenerator, classFile, m);
// mark the next instruction as not forward reachable, // mark the next instruction as not forward reachable,
// this will cause the stack to be loaded from locals // this will cause the stack to be loaded from locals
// (which is needed for the code to be verifiable) // (which is needed for the code to be verifiable)
@ -2781,12 +2784,12 @@ class Compiler
private void GetPutField(Instruction instr, int i) private void GetPutField(Instruction instr, int i)
{ {
NormalizedByteCode bytecode = instr.NormalizedOpCode; NormalizedByteCode bytecode = instr.NormalizedOpCode;
ClassFile.ConstantPoolItemFieldref cpi = m.Method.ClassFile.GetFieldref(instr.Arg1); ClassFile.ConstantPoolItemFieldref cpi = classFile.GetFieldref(instr.Arg1);
bool write = (bytecode == NormalizedByteCode.__putfield || bytecode == NormalizedByteCode.__putstatic); bool write = (bytecode == NormalizedByteCode.__putfield || bytecode == NormalizedByteCode.__putstatic);
TypeWrapper wrapper = cpi.GetClassType(classLoader); TypeWrapper wrapper = cpi.GetClassType();
if(wrapper.IsUnloadable) if(wrapper.IsUnloadable)
{ {
TypeWrapper fieldTypeWrapper = cpi.GetFieldType(classLoader); TypeWrapper fieldTypeWrapper = cpi.GetFieldType();
if(write && !fieldTypeWrapper.IsUnloadable && fieldTypeWrapper.IsPrimitive) if(write && !fieldTypeWrapper.IsUnloadable && fieldTypeWrapper.IsPrimitive)
{ {
ilGenerator.Emit(OpCodes.Box, fieldTypeWrapper.TypeAsTBD); ilGenerator.Emit(OpCodes.Box, fieldTypeWrapper.TypeAsTBD);
@ -2827,11 +2830,11 @@ class Compiler
TypeWrapper thisType = null; TypeWrapper thisType = null;
if(bytecode == NormalizedByteCode.__getfield) if(bytecode == NormalizedByteCode.__getfield)
{ {
thisType = SigTypeToClassName(ma.GetRawStackTypeWrapper(i, 0), cpi.GetClassType(classLoader)); thisType = SigTypeToClassName(ma.GetRawStackTypeWrapper(i, 0), cpi.GetClassType());
} }
else if(bytecode == NormalizedByteCode.__putfield) else if(bytecode == NormalizedByteCode.__putfield)
{ {
thisType = SigTypeToClassName(ma.GetRawStackTypeWrapper(i, 1), cpi.GetClassType(classLoader)); thisType = SigTypeToClassName(ma.GetRawStackTypeWrapper(i, 1), cpi.GetClassType());
} }
bool isStatic = (bytecode == NormalizedByteCode.__putstatic || bytecode == NormalizedByteCode.__getstatic); bool isStatic = (bytecode == NormalizedByteCode.__putstatic || bytecode == NormalizedByteCode.__getstatic);
FieldWrapper field = cpi.GetField(); //wrapper.GetFieldWrapper(cpi.Name, cpi.GetFieldType(classLoader)); FieldWrapper field = cpi.GetField(); //wrapper.GetFieldWrapper(cpi.Name, cpi.GetFieldType(classLoader));
@ -2925,23 +2928,23 @@ class Compiler
internal override void EmitCall(ILGenerator ilgen) internal override void EmitCall(ILGenerator ilgen)
{ {
Emit(dynamicInvokestatic, ilgen, cpi.GetRetType(classLoader)); Emit(dynamicInvokestatic, ilgen, cpi.GetRetType());
} }
internal override void EmitCallvirt(ILGenerator ilgen) internal override void EmitCallvirt(ILGenerator ilgen)
{ {
Emit(dynamicInvokevirtual, ilgen, cpi.GetRetType(classLoader)); Emit(dynamicInvokevirtual, ilgen, cpi.GetRetType());
} }
internal override void EmitNewobj(ILGenerator ilgen) internal override void EmitNewobj(ILGenerator ilgen)
{ {
Emit(dynamicInvokeSpecialNew, ilgen, cpi.GetClassType(classLoader)); Emit(dynamicInvokeSpecialNew, ilgen, cpi.GetClassType());
} }
private void Emit(MethodInfo helperMethod, ILGenerator ilGenerator, TypeWrapper retTypeWrapper) private void Emit(MethodInfo helperMethod, ILGenerator ilGenerator, TypeWrapper retTypeWrapper)
{ {
Profiler.Count("EmitDynamicInvokeEmitter"); Profiler.Count("EmitDynamicInvokeEmitter");
TypeWrapper[] args = cpi.GetArgTypes(classLoader); TypeWrapper[] args = cpi.GetArgTypes();
LocalBuilder argarray = ilGenerator.DeclareLocal(typeof(object[])); LocalBuilder argarray = ilGenerator.DeclareLocal(typeof(object[]));
LocalBuilder val = ilGenerator.DeclareLocal(typeof(object)); LocalBuilder val = ilGenerator.DeclareLocal(typeof(object));
ilGenerator.Emit(OpCodes.Ldc_I4, args.Length); ilGenerator.Emit(OpCodes.Ldc_I4, args.Length);
@ -2971,7 +2974,7 @@ class Compiler
private MethodWrapper GetMethodCallEmitter(ClassFile.ConstantPoolItemMI cpi, TypeWrapper thisType, NormalizedByteCode invoke) private MethodWrapper GetMethodCallEmitter(ClassFile.ConstantPoolItemMI cpi, TypeWrapper thisType, NormalizedByteCode invoke)
{ {
TypeWrapper wrapper = cpi.GetClassType(classLoader); TypeWrapper wrapper = cpi.GetClassType();
if(wrapper.IsUnloadable || (thisType != null && thisType.IsUnloadable)) if(wrapper.IsUnloadable || (thisType != null && thisType.IsUnloadable))
{ {
return new DynamicMethodWrapper(classLoader, clazz, cpi); return new DynamicMethodWrapper(classLoader, clazz, cpi);
@ -3149,11 +3152,11 @@ class Compiler
private bool IsUnloadable(ClassFile.ConstantPoolItemMI cpi) private bool IsUnloadable(ClassFile.ConstantPoolItemMI cpi)
{ {
if(cpi.GetClassType(classLoader).IsUnloadable || cpi.GetRetType(classLoader).IsUnloadable) if(cpi.GetClassType().IsUnloadable || cpi.GetRetType().IsUnloadable)
{ {
return true; return true;
} }
TypeWrapper[] args = cpi.GetArgTypes(classLoader); TypeWrapper[] args = cpi.GetArgTypes();
for(int i = 0; i < args.Length; i++) for(int i = 0; i < args.Length; i++)
{ {
if(args[i].IsUnloadable) if(args[i].IsUnloadable)

Просмотреть файл

@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<project name="IKVM.Runtime" default="IKVM.Runtime"> <project name="IKVM.Runtime" default="IKVM.Runtime">
<target name="IKVM.Runtime"> <target name="IKVM.Runtime">
<csc target="library" output="../bin/IKVM.Runtime.dll" define="TRACE" optimize="true"> <csc target="library" output="../bin/IKVM.Runtime.dll" define="TRACE" optimize="true" unsafe="true">
<sources> <sources>
<includes name="*.cs" /> <includes name="*.cs" />
</sources> </sources>

Просмотреть файл

@ -1051,7 +1051,7 @@ class LocalVar
internal int start_pc; internal int start_pc;
internal int end_pc; internal int end_pc;
internal void FindLvtEntry(ClassFile.Method.Code method, int instructionIndex) internal void FindLvtEntry(ClassFile.Method method, int instructionIndex)
{ {
ClassFile.Method.LocalVariableTableEntry[] lvt = method.LocalVariableTableAttribute; ClassFile.Method.LocalVariableTableEntry[] lvt = method.LocalVariableTableAttribute;
if(lvt != null) if(lvt != null)
@ -1087,7 +1087,8 @@ class MethodAnalyzer
private static TypeWrapper DoubleArrayType; private static TypeWrapper DoubleArrayType;
private static TypeWrapper LongArrayType; private static TypeWrapper LongArrayType;
private ClassLoaderWrapper classLoader; private ClassLoaderWrapper classLoader;
private ClassFile.Method.Code method; private ClassFile classFile;
private ClassFile.Method method;
private InstructionState[] state; private InstructionState[] state;
private ArrayList[] callsites; private ArrayList[] callsites;
private LocalVar[/*instructionIndex*/] localVars; private LocalVar[/*instructionIndex*/] localVars;
@ -1106,9 +1107,10 @@ class MethodAnalyzer
LongArrayType = PrimitiveTypeWrapper.LONG.MakeArrayType(1); LongArrayType = PrimitiveTypeWrapper.LONG.MakeArrayType(1);
} }
internal MethodAnalyzer(TypeWrapper wrapper, ClassFile.Method.Code method, ClassLoaderWrapper classLoader) internal MethodAnalyzer(TypeWrapper wrapper, MethodWrapper mw, ClassFile classFile, ClassFile.Method method, ClassLoaderWrapper classLoader)
{ {
this.classLoader = classLoader; this.classLoader = classLoader;
this.classFile = classFile;
this.method = method; this.method = method;
state = new InstructionState[method.Instructions.Length]; state = new InstructionState[method.Instructions.Length];
callsites = new ArrayList[method.Instructions.Length]; callsites = new ArrayList[method.Instructions.Length];
@ -1124,10 +1126,10 @@ class MethodAnalyzer
// start by computing the initial state, the stack is empty and the locals contain the arguments // start by computing the initial state, the stack is empty and the locals contain the arguments
state[0] = new InstructionState(method.MaxLocals, method.MaxStack); state[0] = new InstructionState(method.MaxLocals, method.MaxStack);
int firstNonArgLocalIndex = 0; int firstNonArgLocalIndex = 0;
if(!method.Method.IsStatic) if(!method.IsStatic)
{ {
// this reference. If we're a constructor, the this reference is uninitialized. // this reference. If we're a constructor, the this reference is uninitialized.
if(method.Method.Name == "<init>") if(method.Name == "<init>")
{ {
state[0].SetLocalType(firstNonArgLocalIndex++, VerifierTypeWrapper.UninitializedThis, -1); state[0].SetLocalType(firstNonArgLocalIndex++, VerifierTypeWrapper.UninitializedThis, -1);
} }
@ -1136,7 +1138,7 @@ class MethodAnalyzer
state[0].SetLocalType(firstNonArgLocalIndex++, wrapper, -1); state[0].SetLocalType(firstNonArgLocalIndex++, wrapper, -1);
} }
} }
TypeWrapper[] argTypeWrappers = method.Method.GetArgTypes(classLoader); TypeWrapper[] argTypeWrappers = mw.GetParameters();
for(int i = 0; i < argTypeWrappers.Length; i++) for(int i = 0; i < argTypeWrappers.Length; i++)
{ {
TypeWrapper type = argTypeWrappers[i]; TypeWrapper type = argTypeWrappers[i];
@ -1157,10 +1159,11 @@ class MethodAnalyzer
} }
InstructionState s = state[0].Copy(); InstructionState s = state[0].Copy();
bool done = false; bool done = false;
ClassFile.Method.Instruction[] instructions = method.Instructions;
while(!done) while(!done)
{ {
done = true; done = true;
for(int i = 0; i < method.Instructions.Length; i++) for(int i = 0; i < instructions.Length; i++)
{ {
if(state[i] != null && state[i].changed) if(state[i] != null && state[i].changed)
{ {
@ -1172,7 +1175,7 @@ class MethodAnalyzer
// mark the exception handlers reachable from this instruction // mark the exception handlers reachable from this instruction
for(int j = 0; j < method.ExceptionTable.Length; j++) for(int j = 0; j < method.ExceptionTable.Length; j++)
{ {
if(method.ExceptionTable[j].start_pc <= method.Instructions[i].PC && method.ExceptionTable[j].end_pc > method.Instructions[i].PC) if(method.ExceptionTable[j].start_pc <= instructions[i].PC && method.ExceptionTable[j].end_pc > instructions[i].PC)
{ {
// NOTE this used to be CopyLocalsAndSubroutines, but it doesn't (always) make // NOTE this used to be CopyLocalsAndSubroutines, but it doesn't (always) make
// sense to copy the subroutine state // sense to copy the subroutine state
@ -1198,7 +1201,7 @@ class MethodAnalyzer
} }
} }
state[i].CopyTo(s); state[i].CopyTo(s);
ClassFile.Method.Instruction instr = method.Instructions[i]; ClassFile.Method.Instruction instr = instructions[i];
switch(instr.NormalizedOpCode) switch(instr.NormalizedOpCode)
{ {
case NormalizedByteCode.__aload: case NormalizedByteCode.__aload:
@ -1378,17 +1381,17 @@ class MethodAnalyzer
s.PopObjectType(); s.PopObjectType();
break; break;
case NormalizedByteCode.__getstatic: case NormalizedByteCode.__getstatic:
s.PushType((GetFieldref(instr.Arg1)).GetFieldType(classLoader)); s.PushType((GetFieldref(instr.Arg1)).GetFieldType());
break; break;
case NormalizedByteCode.__putstatic: case NormalizedByteCode.__putstatic:
s.PopType(GetFieldref(instr.Arg1).GetFieldType(classLoader)); s.PopType(GetFieldref(instr.Arg1).GetFieldType());
break; break;
case NormalizedByteCode.__getfield: case NormalizedByteCode.__getfield:
s.PopObjectType(GetFieldref(instr.Arg1).GetClassType(classLoader)); s.PopObjectType(GetFieldref(instr.Arg1).GetClassType());
s.PushType(GetFieldref(instr.Arg1).GetFieldType(classLoader)); s.PushType(GetFieldref(instr.Arg1).GetFieldType());
break; break;
case NormalizedByteCode.__putfield: case NormalizedByteCode.__putfield:
s.PopType(GetFieldref(instr.Arg1).GetFieldType(classLoader)); s.PopType(GetFieldref(instr.Arg1).GetFieldType());
// putfield is allowed to access the unintialized this // putfield is allowed to access the unintialized this
if(s.PeekType() == VerifierTypeWrapper.UninitializedThis) if(s.PeekType() == VerifierTypeWrapper.UninitializedThis)
{ {
@ -1396,7 +1399,7 @@ class MethodAnalyzer
} }
else else
{ {
s.PopObjectType(GetFieldref(instr.Arg1).GetClassType(classLoader)); s.PopObjectType(GetFieldref(instr.Arg1).GetClassType());
} }
break; break;
case NormalizedByteCode.__ldc: case NormalizedByteCode.__ldc:
@ -1419,7 +1422,7 @@ class MethodAnalyzer
s.PushType(CoreClasses.java.lang.String.Wrapper); s.PushType(CoreClasses.java.lang.String.Wrapper);
break; break;
case ClassFile.ConstantType.Class: case ClassFile.ConstantType.Class:
if(method.Method.ClassFile.MajorVersion < 49) if(classFile.MajorVersion < 49)
{ {
throw new VerifyError("Illegal type in constant pool"); throw new VerifyError("Illegal type in constant pool");
} }
@ -1450,7 +1453,7 @@ class MethodAnalyzer
{ {
throw new VerifyError("Illegal call to internal method"); throw new VerifyError("Illegal call to internal method");
} }
TypeWrapper[] args = cpi.GetArgTypes(classLoader); TypeWrapper[] args = cpi.GetArgTypes();
for(int j = args.Length - 1; j >= 0; j--) for(int j = args.Length - 1; j >= 0; j--)
{ {
s.PopType(args[j]); s.PopType(args[j]);
@ -1466,8 +1469,8 @@ class MethodAnalyzer
if(cpi.Name == "<init>") if(cpi.Name == "<init>")
{ {
TypeWrapper type = s.PopType(); TypeWrapper type = s.PopType();
if((VerifierTypeWrapper.IsNew(type) && ((VerifierTypeWrapper)type).UnderlyingType != cpi.GetClassType(classLoader)) || if((VerifierTypeWrapper.IsNew(type) && ((VerifierTypeWrapper)type).UnderlyingType != cpi.GetClassType()) ||
(type == VerifierTypeWrapper.UninitializedThis && cpi.GetClassType(classLoader) != wrapper.BaseTypeWrapper && cpi.GetClassType(classLoader) != wrapper) || (type == VerifierTypeWrapper.UninitializedThis && cpi.GetClassType() != wrapper.BaseTypeWrapper && cpi.GetClassType() != wrapper) ||
(!VerifierTypeWrapper.IsNew(type) && type != VerifierTypeWrapper.UninitializedThis)) (!VerifierTypeWrapper.IsNew(type) && type != VerifierTypeWrapper.UninitializedThis))
{ {
// TODO oddly enough, Java fails verification for the class without // TODO oddly enough, Java fails verification for the class without
@ -1493,7 +1496,7 @@ class MethodAnalyzer
if(instr.NormalizedOpCode != NormalizedByteCode.__invokeinterface) if(instr.NormalizedOpCode != NormalizedByteCode.__invokeinterface)
{ {
TypeWrapper refType = s.PopObjectType(); TypeWrapper refType = s.PopObjectType();
TypeWrapper targetType = cpi.GetClassType(classLoader); TypeWrapper targetType = cpi.GetClassType();
if(!VerifierTypeWrapper.IsNullOrUnloadable(refType) && if(!VerifierTypeWrapper.IsNullOrUnloadable(refType) &&
!targetType.IsUnloadable && !targetType.IsUnloadable &&
!refType.IsAssignableTo(targetType)) !refType.IsAssignableTo(targetType))
@ -1522,7 +1525,7 @@ class MethodAnalyzer
} }
} }
} }
TypeWrapper retType = cpi.GetRetType(classLoader); TypeWrapper retType = cpi.GetRetType();
if(retType != PrimitiveTypeWrapper.VOID) if(retType != PrimitiveTypeWrapper.VOID)
{ {
s.PushType(retType); s.PushType(retType);
@ -1832,19 +1835,18 @@ class MethodAnalyzer
s.PopObjectType(); s.PopObjectType();
break; break;
case NormalizedByteCode.__return: case NormalizedByteCode.__return:
if(method.Method.GetRetType(classLoader) != PrimitiveTypeWrapper.VOID) if(mw.ReturnType != PrimitiveTypeWrapper.VOID)
{ {
throw new VerifyError("Wrong return type in function"); throw new VerifyError("Wrong return type in function");
} }
break; break;
case NormalizedByteCode.__areturn: case NormalizedByteCode.__areturn:
s.PopObjectType(method.Method.GetRetType(classLoader)); s.PopObjectType(mw.ReturnType);
break; break;
case NormalizedByteCode.__ireturn: case NormalizedByteCode.__ireturn:
{ {
s.PopInt(); s.PopInt();
TypeWrapper retType = method.Method.GetRetType(classLoader); if(!mw.ReturnType.IsIntOnStackPrimitive)
if(!retType.IsIntOnStackPrimitive)
{ {
throw new VerifyError("Wrong return type in function"); throw new VerifyError("Wrong return type in function");
} }
@ -1852,21 +1854,21 @@ class MethodAnalyzer
} }
case NormalizedByteCode.__lreturn: case NormalizedByteCode.__lreturn:
s.PopLong(); s.PopLong();
if(method.Method.GetRetType(classLoader) != PrimitiveTypeWrapper.LONG) if(mw.ReturnType != PrimitiveTypeWrapper.LONG)
{ {
throw new VerifyError("Wrong return type in function"); throw new VerifyError("Wrong return type in function");
} }
break; break;
case NormalizedByteCode.__freturn: case NormalizedByteCode.__freturn:
s.PopFloat(); s.PopFloat();
if(method.Method.GetRetType(classLoader) != PrimitiveTypeWrapper.FLOAT) if(mw.ReturnType != PrimitiveTypeWrapper.FLOAT)
{ {
throw new VerifyError("Wrong return type in function"); throw new VerifyError("Wrong return type in function");
} }
break; break;
case NormalizedByteCode.__dreturn: case NormalizedByteCode.__dreturn:
s.PopDouble(); s.PopDouble();
if(method.Method.GetRetType(classLoader) != PrimitiveTypeWrapper.DOUBLE) if(mw.ReturnType != PrimitiveTypeWrapper.DOUBLE)
{ {
throw new VerifyError("Wrong return type in function"); throw new VerifyError("Wrong return type in function");
} }
@ -2014,7 +2016,7 @@ class MethodAnalyzer
break; break;
} }
case NormalizedByteCode.__nop: case NormalizedByteCode.__nop:
if(i + 1 == method.Method.CodeAttribute.Instructions.Length) if(i + 1 == instructions.Length)
{ {
throw new VerifyError("Falling off the end of the code"); throw new VerifyError("Falling off the end of the code");
} }
@ -2032,9 +2034,9 @@ class MethodAnalyzer
switch(instr.NormalizedOpCode) switch(instr.NormalizedOpCode)
{ {
case NormalizedByteCode.__lookupswitch: case NormalizedByteCode.__lookupswitch:
for(int j = 0; j < instr.Values.Length; j++) for(int j = 0; j < instr.SwitchEntryCount; j++)
{ {
state[method.PcIndexMap[instr.PC + instr.TargetOffsets[j]]] += s; state[method.PcIndexMap[instr.PC + instr.GetSwitchTargetOffset(j)]] += s;
} }
state[method.PcIndexMap[instr.PC + instr.DefaultOffset]] += s; state[method.PcIndexMap[instr.PC + instr.DefaultOffset]] += s;
break; break;
@ -2125,12 +2127,12 @@ class MethodAnalyzer
} }
catch(VerifyError x) catch(VerifyError x)
{ {
string opcode = method.Instructions[i].OpCode.ToString(); string opcode = instructions[i].OpCode.ToString();
if(opcode.StartsWith("__")) if(opcode.StartsWith("__"))
{ {
opcode = opcode.Substring(2); opcode = opcode.Substring(2);
} }
x.SetInfo(method.Instructions[i].PC, method.Method.ClassFile.Name, method.Method.Name, method.Method.Signature, opcode); x.SetInfo(instructions[i].PC, classFile.Name, method.Name, method.Signature, opcode);
Tracer.Info(Tracer.Verifier, x.ToString()); Tracer.Info(Tracer.Verifier, x.ToString());
throw; throw;
} }
@ -2152,14 +2154,14 @@ class MethodAnalyzer
if(JVM.Debug) if(JVM.Debug)
{ {
// if we're emitting debug info, we need to keep dead stores as well... // if we're emitting debug info, we need to keep dead stores as well...
for(int i = 0; i < method.Instructions.Length; i++) for(int i = 0; i < instructions.Length; i++)
{ {
if(IsStoreLocal(method.Instructions[i].NormalizedOpCode)) if(IsStoreLocal(instructions[i].NormalizedOpCode))
{ {
if(!localByStoreSite.ContainsKey(i + ":" + method.Instructions[i].NormalizedArg1)) if(!localByStoreSite.ContainsKey(i + ":" + instructions[i].NormalizedArg1))
{ {
LocalVar v = new LocalVar(); LocalVar v = new LocalVar();
v.local = method.Instructions[i].NormalizedArg1; v.local = instructions[i].NormalizedArg1;
v.type = GetRawStackTypeWrapper(i, 0); v.type = GetRawStackTypeWrapper(i, 0);
v.FindLvtEntry(method, i); v.FindLvtEntry(method, i);
locals.Add(v); locals.Add(v);
@ -2214,25 +2216,25 @@ class MethodAnalyzer
} }
} }
} }
invokespecialLocalVars = new LocalVar[method.Instructions.Length][]; invokespecialLocalVars = new LocalVar[instructions.Length][];
localVars = new LocalVar[method.Instructions.Length]; localVars = new LocalVar[instructions.Length];
for(int i = 0; i < localVars.Length; i++) for(int i = 0; i < localVars.Length; i++)
{ {
LocalVar v = null; LocalVar v = null;
if(localStoreReaders[i] != null) if(localStoreReaders[i] != null)
{ {
Debug.Assert(IsLoadLocal(method.Instructions[i].NormalizedOpCode)); Debug.Assert(IsLoadLocal(instructions[i].NormalizedOpCode));
// lame way to look up the local variable for a load // lame way to look up the local variable for a load
// (by indirecting through a corresponding store) // (by indirecting through a corresponding store)
foreach(int store in localStoreReaders[i].Keys) foreach(int store in localStoreReaders[i].Keys)
{ {
v = (LocalVar)localByStoreSite[store + ":" + method.Instructions[i].NormalizedArg1]; v = (LocalVar)localByStoreSite[store + ":" + instructions[i].NormalizedArg1];
break; break;
} }
} }
else else
{ {
if(method.Instructions[i].NormalizedOpCode == NormalizedByteCode.__invokespecial) if(instructions[i].NormalizedOpCode == NormalizedByteCode.__invokespecial)
{ {
invokespecialLocalVars[i] = new LocalVar[method.MaxLocals]; invokespecialLocalVars[i] = new LocalVar[method.MaxLocals];
for(int j = 0; j < invokespecialLocalVars[i].Length; j++) for(int j = 0; j < invokespecialLocalVars[i].Length; j++)
@ -2242,7 +2244,7 @@ class MethodAnalyzer
} }
else else
{ {
v = (LocalVar)localByStoreSite[i + ":" + method.Instructions[i].NormalizedArg1]; v = (LocalVar)localByStoreSite[i + ":" + instructions[i].NormalizedArg1];
} }
} }
if(v != null) if(v != null)
@ -2392,7 +2394,7 @@ class MethodAnalyzer
{ {
try try
{ {
ClassFile.ConstantPoolItemMI item = method.Method.ClassFile.GetMethodref(index); ClassFile.ConstantPoolItemMI item = classFile.GetMethodref(index);
if(item != null) if(item != null)
{ {
return item; return item;
@ -2411,7 +2413,7 @@ class MethodAnalyzer
{ {
try try
{ {
ClassFile.ConstantPoolItemFieldref item = method.Method.ClassFile.GetFieldref(index); ClassFile.ConstantPoolItemFieldref item = classFile.GetFieldref(index);
if(item != null) if(item != null)
{ {
return item; return item;
@ -2430,7 +2432,7 @@ class MethodAnalyzer
{ {
try try
{ {
return method.Method.ClassFile.GetConstantPoolConstantType(index); return classFile.GetConstantPoolConstantType(index);
} }
catch(IndexOutOfRangeException) catch(IndexOutOfRangeException)
{ {
@ -2451,7 +2453,7 @@ class MethodAnalyzer
{ {
try try
{ {
return method.Method.ClassFile.GetConstantPoolClass(index); return classFile.GetConstantPoolClass(index);
} }
catch(InvalidCastException) catch(InvalidCastException)
{ {
@ -2466,7 +2468,7 @@ class MethodAnalyzer
{ {
try try
{ {
return method.Method.ClassFile.GetConstantPoolClassType(index, classLoader); return classFile.GetConstantPoolClassType(index);
} }
catch(InvalidCastException) catch(InvalidCastException)
{ {

Просмотреть файл

@ -36,7 +36,6 @@ public class JVM
private static bool debug = false; private static bool debug = false;
private static bool noJniStubs = false; private static bool noJniStubs = false;
private static bool isStaticCompiler = false; private static bool isStaticCompiler = false;
private static IJniProvider jniProvider;
private static bool compilationPhase1; private static bool compilationPhase1;
private static string sourcePath; private static string sourcePath;
@ -108,38 +107,6 @@ public class JVM
} }
} }
public static IJniProvider JniProvider
{
get
{
if(jniProvider == null)
{
Type provider;
string providerAssembly = Environment.GetEnvironmentVariable("IKVM_JNI_PROVIDER");
if(providerAssembly != null)
{
Tracer.Info(Tracer.Runtime, "Loading environment specified JNI provider: {0}", providerAssembly);
provider = Assembly.LoadFrom(providerAssembly).GetType("JNI", true);
}
else
{
if(IsUnix)
{
Tracer.Info(Tracer.Runtime, "Loading JNI provider: IKVM.JNI.Mono");
provider = Assembly.LoadWithPartialName("IKVM.JNI.Mono").GetType("JNI", true);
}
else
{
Tracer.Info(Tracer.Runtime, "Loading JNI provider: IKVM.JNI.CLR-Win32");
provider = Assembly.LoadWithPartialName("IKVM.JNI.CLR-Win32").GetType("JNI", true);
}
}
jniProvider = (IJniProvider)Activator.CreateInstance(provider);
}
return jniProvider;
}
}
private class CompilerClassLoader : ClassLoaderWrapper private class CompilerClassLoader : ClassLoaderWrapper
{ {
private Hashtable classes; private Hashtable classes;
@ -1355,7 +1322,7 @@ public class JVM
ClassFile f; ClassFile f;
try try
{ {
f = new ClassFile(classes[i], 0, classes[i].Length, null); f = new ClassFile(classes[i], 0, classes[i].Length, null, true);
} }
catch(UnsupportedClassVersionError x) catch(UnsupportedClassVersionError x)
{ {