android学习格式安卓ndk的之旅_第1页
android学习格式安卓ndk的之旅_第2页
android学习格式安卓ndk的之旅_第3页
android学习格式安卓ndk的之旅_第4页
android学习格式安卓ndk的之旅_第5页
已阅读5页,还剩313页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

jni.bookPagePAGE1Thursday,February21,20024:36jni.bookPagePAGE1Thursday,February21,20024:36Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 ShengADDISON-AnimprintofAddisonWesleyLongman,Reading,Massachusetts•Harlow,England•MenloPark,CaliforniaBerkeley,California•DonMills,Ontario•SydneyBonn•Amsterdam•Tokyo•MexicoCity901SanAntonioRoad,PaloAlto,CA94303USA.Allrights.SunMicrosystems,Inc.hasinlectualpropertyrightsrelatingtoimplementationsofthetechnologydescribedinthispublication.Inparticular,andwithoutlimitation,theseinlectualpropertyrightsmayincludeoneormoreU.S.patents,foreignpatents,orpendingapplications.Sun,SunMicrosystems,theSunlogo,andallSun,Java,Jini,andSolarisbasedtrademarksandlogosaretrademarksorregisteredtrademarksofSunMicrosystems,IheUnitedStatesandotherthroughX/Open,.SunMicrosystems,Inc.(SUN)herebygrantstoyouafullypaid,nonexclusive,nontransferable,perpetual,worldwidelimitedlicense(withouttherighttosublicense)underSUN’sinlectualpropertyrightsthatareessentialtopracticethisspecification.Thislicenseallowsandislimitedtothecreationanddistributionofcleanroomimplementationsofthisspecificationthat:(i)includea(ii)implementalltherequiredinterfacesandfunctionalityoftheJava™2tform,StandardEdition,asdefinedbySUN,withoutsubsettingorsupersetting;(iii)donotaddanyadditionalpackages,classes,orinterfacestothejava.*orjavax.*packagesortheirsubpackages;(iv)passalltestsuitesrelatingtothemostrecentpublishedversionofthespecificationoftheJava™2tform,StandardEdition,thatareavailablefromSUNsix(6)monthspriortoanybetareleaseofthecleanroomimplementationorupgradethereto;(v)donotderivefromSUNsourcecodeorbinarymaterials;(vi)donotincludeanySUNsourcecodeorbinarymaterialswithoutanappropriateandseparatelicensefromSUN.U.S.ERNMENTUSE:Thisspecificationrelatestocommercialitems,processes,orsoftware.Accordingly,usebytheUnitedStatesernmentissubjecttothesetermsandconditions,consistentwithFAR12.211and12.212.EXPRESSORIMPLIED,INCLUDING,BUTNOTLIMITEDTO,THEIMPLIEDWARRANTIESOFMERCHANTABILITY,FITNESSFORAPARTICULARPURPOSE,ORNON-INFRINGE-THISPUBLICATIONCOULDINCLUDETECHNICALINACCURACIESORTYPOGRAPHI-CALERRORS.CHANGESAREPERIODICALLYADDEDTOTHEINFORMATIONHEREIN;THESECHANGESWILLBEINCORPORATEDINNEWEDITIONSOFTHEPUBLICATION.SUNMICROSYSTEMS,INC.MAYMAKEIMPROVEMENTSAND/ORCHANGESINANYTECHNOLOGY,PRODUCT,ORPROGRAMDESCRIBEDINTHISPUBLICATIONATANYThepublisheroffersdiscountsonthisbookwhenorderedintyforspecialsales.Formoreinformation,pleasecontacttheCorporate,ernment,andSpecialSalesGroup,CEPUB,AddisonWesleyLongman,Inc.,OneJacobWay,Reading,Massachusetts01867.ISBN0-201-32577-123456789-Firstprinting,JuneTotheVMjni.bookPageviiThursday,February21,20024:36jni.bookPageviiThursday,February21,20024:36Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 PartOne:Introductionand The tformandHost Roleofthe ImplicationsofUsingthe WhentoUsethe Evolutionofthe Example Getting DeclaretheNative Compile oWorld CreatetheNativeMethodHeader WritetheNativeMethod CompiletheCSourceandCreateaNative Runthe PartTwo:Programmer’sBasicTypes,Strings,and ASimpleNativeMethod..................................... CPrototypeforImplementingtheNativeMethod........... NativeMethodArguments............................. ofTypes................................... AccessingStrings........................................... ConvertingtoNativeStrings........................... ingNativeStringResources........................ ConstructingNewStrings............................. OtherJNIStringFunctions............................ NewJNIStringFunctionsinJava2SDKRelease1.2...jni.bookPagePAGE\*romanviiiThursday,February21,20024:36jni.bookPagePAGE\*romanviiiThursday,February21,20024:36Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 SummaryofJNIString ChoosingamongtheString Accessing AccessingArraysin AccessingArraysofPrimitive SummaryofJNIPrimitiveArray ChoosingamongthePrimitiveArray AccessingArraysof Fieldsand Accessing ProcedureforAccessinganInstance Field AccessingStatic Calling CallingInstance FormingtheMethod CallingStatic CallingInstanceMethodsofa Invoking CachingFieldandMethod CachingatthePointof CachingintheDefiningClass’s ComparisonbetweentheTwoApproachestoCaching PerformanceofJNIFieldandMethod LocalandGlobal LocalandGlobal Local Global WeakGlobal Comparing ing ingLocal ManagingLocalReferencesinJava2SDKRelease ingGlobal RulesforManaging CachingandThrowingExceptionsinNative AUtility ProperException Checkingfor Handling ExceptionsinUtility TheInvocation CreatingtheJavaVirtual LinkingNativeApplicationswiththeJavaVirtual LinkingwithaKnownJavaVirtual LinkingwithUnknownJavaVirtual AttachingNative AdditionalJNI JNIand MonitorEntryand MonitorWaitand ObtainingaJNIEnvPointerinArbitrary MatchingtheThread WritingInternationalized CreatingjstringsfromNative TranslatingjstringstoNative RegisteringNative LoadandUnload TheJNI_OnLoad TheJNI_OnUnload Reflection JNIProgrammingin LeveragingExistingNative One-to-OneMap........................................Shared One-to-OneMapversusShared ImplementationofShared TheCPointer TheCMalloc TheCFunction Peer PeerClassesinthe ingNativeData BackpointerstoPeer Trapsand Error PassingInvalidArgumentstoJNI Confusingjclasswith Truncatingjboolean BoundariesbetweenJavaApplicationandNative ConfusingIDswith CachingFieldandMethod TerminatingUnicode ViolatingAccessControl RetainingVirtualMachine ExcessiveLocalReference UsingInvalidLocal UsingtheJNIEnvacross MismatchedThread PartThree:OverviewoftheJNI Design LoadingNative Class ClassLoadersandNative LocatingNative ATypeSafety UnloadingNative LinkingNative Calling TheJNIEnvInterface OrganizationoftheJNIEnvInterface BenefitsofanInterface Passing GlobalandLocal ImplementingLocal WeakGlobal Accessing AccessingPrimitive Fieldsand Errorsand NoCheckingforProgramming JavaVirtualMachine Asynchronous JNI PrimitiveandReference Primitive Reference Thejvalue FieldandMethod String UTF-8 Class Field Method xJNI SummaryoftheJNI Directly-ExportedInvocationInterface TheJavaVM FunctionsDefinedinNative TheJNIEnv SpecificationofJNI jni.bookPagexiiThursday,February21,20024:36jni.bookPagexiiThursday,February21,20024:36Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 jni.bookPagePAGE\*romanxiiiThursday,February21,20024:36jni.bookPagePAGE\*romanxiiiThursday,February21,20024:36Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 THISbookcoverstheJava™NativeInterface(JNI).Itwillbeusefultoyouifyouareinterestedinanyofthefollowing:integratingaJavaapplicationwithlegacycodewritteninlanguagessuchasCorC++incorporatingaJavavirtualmachineimplementationintoanexistingapplica-tionwritteninlanguagessuchasCorC++implementingaJavavirtualunderstandingthetechnicalissuesinlanguageinteroperability,inparticularhowtohandlefeaturessuchasgarbagecollectionandmultithreadingFirstandforemost,thebookiswrittenfordevelopers.YouwillfindeasystepstogetstartedwiththeJNI,informativediscussionsonvariousJNIfeatures,andhelpfultipsonhowtousetheJNIeffectively.TheJNIwasinitiallyreleasedinearly1997.ThebooksummarizestwoyearsofcollectiveexperiencegainedbyengineersatSunMicrosystemsaswellasthevastnumberofdevelopersintheJavatechnologycommunity.Second,thebookpresentsthedesignrationaleofvariousJNIfeatures.Notonlyisthisofinteresttotheacademiccommunity,butathoroughunderstandingofthedesignisalsoaprerequisitetousingtheJNIeffectively.Third,apartofthebookisthedefinitiveJNIspecificationfortheJava2t-form.JNIprogrammersmayusethespecificationasareferencemanual.Javavir-tualmachineimplementorsmustfollowthespecificationtoachieveconformance.SendcommentsonthisspecificationorquestionsaboutJNItoourelectronicmailaddress: .ForthelatestontheJava2tform,ortogetthelatestJava2SDKrelease,visitourwebsiteath .ForupdatedinformationaboutTheJava™Series,includingerrataforthisbook,previews ingbooks,visit TheJNIwasdesignedfollowingaseriesofdiscussionsbetweenSunMicro-systemsandJavatechnologylicensees.TheJNIpartlyevolvedfromNetscape’sJavaRuntimeInterface(JRI),whichwasdesignedbyWarrenHarris.ManyfromJavatechnologylicenseecompaniesactivelyparticipatedinthedesigndis-cussions.TheyincludeRussArun(),PatrickBeard(Apple),SimonNash(IBM),KenRoot(In),IanEllison-Taylor(),andMikeTou-tonghi().TheJNIdesignalsobenefitedgreatlyfromSuninternaldesignreviewscon-ductedbyDaveBowen,JamesGosling,PeterKessler,TimLindholm,MarkRein-hold,DerekWhite,andFrankYellin.DaveBrown,DaveConnelly,JamesMcIlree,BenjaminRenaud,andTomRodriguezmadesignificantcontributionstotheJNIenhancementsinJava2SDK1.2.CarlaSchroer’steamofcompatibilitytestersinNovosibirsk,Russia,wrotecompatibilitytestsfortheJNI.Intheprocesstheyuncoveredceswheretheoriginalspecificationwasunclearor TheJNItechnologywouldnothavebeendevelopedanddeployedwithoutthemanagementsupportofDaveBowen,LarryAbrahams,DickNeiss, gaard,andAlanBaratz.IreceivedfullsupportandencouragementtoworkonthisbookfrommymanagerDaveTimLindholm,authorofTheJava™VirtualMachineSpecification,ledtheJavavirtualmachinedevelopmenteffortatthetimewhentheJNIwasbeingdesigned.Timdidpioneeringworkonthevirtualmachineandnativeinterfaces,advocatedtheuseoftheJNI,andaddedrigorandclaritytothisbook.Healsopro-videdtheinitialsketchforthisbook’s“kitchenanddiningroom”coverartdesign.Thisbookbenefitedfromthehelpofmanycolleagues.AnandPalaniswamywroteaportionofChapter10oncommontrapsandpitfalls.JanetKoenigcare-fullyreviewedapreliminarydraftandcontributedmanyusefulideas.StearnswroteadraftofChapter2basedontheonlineJNIIreceivedvaluablecommentsonadraftofthisbookfromCraigJ.Bordelon,MichaelBrundage,MaryDageforde,JoshuaEngel,andElliottHughes.LisaFriendly,editorofTheJava™Series,wasinstrumentalingettingthisbookwrittenandpublished.KenArnold,authorofTheJava™ProgrammingLanguage,firstsuggestedthataJNIbookbewritten.IamindebtedtoMikeHen-driksonandMarinaLangatAddison-Wesleyfortheirhelpandtheirpatiencethroughouttheprocess.Dianedoversawtheproductionprocessfromcopyeditingtofinalprinting.InthepastseveralyearsIhavehadtheprivilegeofworkingwithagroupoftalentedanddedicatedpeopleinJavaSoftwareatSunMicrosystems,inparticularmembersoftheoriginal,HotSpot,andSunLabsvirtualmachineteams.Thisbookisdedicatedtothem.ShengLiangMay1999jni.bookPagePAGE100Thursday,February21,20024:36jni.bookPagePAGE100Thursday,February21,20024:36Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 Linux公社)是包括Ubuntu,Fedora,SUSEIT资讯等Linux。 PartOne:IntroductionandCHAPTERTHEJava™NativeInterface(JNI)isapowerfulfeatureoftheJavatform.ApplicationsthatusetheJNIcanincorporatenativecodewritteninprogramminglanguagessuchasCandC++,aswellascodewrittenintheJavalanguage.TheJNIallowsprogrammerstotakeadvantageofthepoweroftheJavatform,withouthavingtoabandontheirinvestmentsinlegacycode.BecausetheJNIisapartoftheJavatform,programmerscanaddressinteroperabilityissuesonce,andexpecttheirsolutiontoworkwithallimplementationsoftheJavat-ThisbookisbothaprogrammingguideandareferencemanualfortheJNI.Thebookconsistsofthreeparts:Chapter2introducestheJNIthroughasimpleexample.ItisatutorialintendedforthebeginninguserswhoareunfamiliarwiththeJNI.Chapters3to10constituteaprogrammer’sguidethatgivesabroadoverviewofanumberofJNIfeatures.Wewillgothoughaseriesofshortbutdescrip-tiveexamplestohighlightvariousJNIfeaturesandtopresentthetechniquesthathaveproventobeusefulinJNIprogramming.Chapters11to13presentthedefinitivespecificationforallJNItypesandfunctions.Thesechaptersarealsoorganizedtoserveasareferencemanual.ThisbooktriestoappealtoawideaudiencewithdifferentneedsfortheJNI.Thetutorialandprogrammingguidearetargetedtowardbeginningprogrammers,whereasexperienceddevelopersandJNIimplementorsmayfindthereferencesectionsmoreuseful.ThemajorityofreaderswilllikelybedeveloperswhousetheJNItowriteapplications.Theterm“you”inthisbookwillimplicitlydenotedeveloperswhoprogramwiththeJNI,asopposedtoJNIimplementorsorend-usersofapplicationswrittenusingtheJNI.ThebookassumesthatyouhavebasicknowledgeoftheJava,C,andC++programminglanguages.Ifnot,youmayrefertooneofthemanyexcellentbooksthatareavailable:TheJava™ProgrammingLanguage,SecondEdition,byKenArnoldandJamesGosling(Addison-Wesley,1998),TheCProgrammingLan-guage,SecondEdition,byBrianKernighanandDennisRitchie(Prentice3The tformandHost 1988),andTheC++ProgrammingLanguage,ThirdEdition,byBjarneStrous-trup(Addison-Wesley,1997).Theremainderofthischapterintroducesthebackground,role,andevolutionoftheJNI.The tformandHostBecausethisbookcoversapplicationswrittenintheJavaprogramminglanguageaswellasinnative(C,C++,etc.)programminglanguages,letusfirstclarifytheexactscopeoftheprogrammingenvironmentsfortheselanguages.TheJavatformisaprogrammingenvironmentconsistingoftheJavavir-tualmachine(VM)andtheJavaApplicationProgrammingInterface(API).1JavaapplicationsarewrittenintheJavaprogramminglanguage,andcompiledintoamachine-independentbinaryclassformat.AclasscanbeexecutedonanyJavavirtualmachineimplementation.TheJavaAPIconsistsofasetofclasses.AnyimplementationoftheJavatformisguaranteedtosupporttheJavaprogramminglanguage,virtualmachine,andAPI.Thetermhostenvironmentrepresentsthehostoperatingsystem,asetofnativelibraries,andtheCPUinstructionset.NativeapplicationsarewritteninnativeprogramminglanguagessuchasCandC++,compiledintohost-specificbinarycode,andlinkedwithnativelibraries.Nativeapplicationsandnativelibrar-iesaretypicallydependentonaparticularhostenvironment.ACapplicationbuiltforoneoperatingsystem,forexample,typicallydoesnotworkonotheroperatingJavatformsarecommonlydeployedontopofahostenvironment.Forexample,theJavaRuntimeEnvironment(JRE)isaSunproductthatsupportstheJavatformonexistingoperatingsystemssuchasSolarisandWindows.TheJavatformoffersasetoffeaturesthatapplicationscanrelyonindependentoftheunderlyinghostenvironment.RoleoftheWhentheJavatformisdeployedontopofhostenvironments,itmay desirableornecessarytoallowJavaapplicationstoworkcloselywithnativecodewritteninotherlanguages.ProgrammershavebeguntoadopttheJavatformtobuildapplicationsthatweretraditionallywritteninCandC++.Becauseof1.Asusedherein,thephrases“Javavirtualmachine”or“JavaVM”meanavirtualmachinefortheJavatform.Similarly,thephrase“JavaAPI”meanstheAPIfortheJavatform.4 Roleofthe existinginvestmentinlegacycode,however,JavaapplicationswillcoexistwithCandC++codeformanyyearstocome.TheJNIisapowerfulfeaturethatallowsyoutotakeadvantageoftheJavatform,butstillutilizecodewritteninotherlanguages.AsapartoftheJavavir-tualmachineimplementation,theJNIisatwo-wayinterfacethatallowsJavaapplicationstoinvokenativecodeandviceversa.Figure1.1illustratestheroleoftheJNI.andlibraryJavavirtualmachine andlibraryJavavirtualmachine andlibraryHostFigure1.1RoleoftheTheJNIisdesignedtohandlesituationswhereyouneedtocombineJavaapplicationswithnativecode.Asatwo-wayinterface,theJNIcansupporttwotypesofnativecode:nativelibrariesandnativeapplications.YoucanusetheJNItowritenativemethodsthatallowJavaapplicationstocallfunctionsimplementedinnativelibraries.JavaapplicationscallnativemethodsinthesamewaythattheycallmethodsimplementedintheJavapro-gramminglanguage.Behindthescenes,however,nativemethodsareimple-mentedinanotherlanguageandresideinnativelibraries.TheJNIsupportsaninvocationinterfacethatallowsyoutoembedaJavavir-tualmachineimplementationintonativeapplications.NativeapplicationscanlinkwithanativelibrarythatimplementstheJavavirtualmachine,andthenusetheinvocationinterfacetoexecutesoftwarecomponentswrittenintheJavaprogramminglanguage.Forexample,awebbrowserwritteninCcanexecutedownloadedappletsinanembeddedJavavirtualmachineimplemen-5ImplicationsofUsingthe ImplicationsofUsingtheRememberthatonceanapplicationusestheJNI,itriskslosingtwobenefitsoftheJavatform.First,JavaapplicationsthatdependontheJNIcannolongerreadilyrunonmultiplehostenvironments.EventhoughthepartofanapplicationwrittenintheJavaprogramminglanguageisportabletomultiplehostenvironments,itwillbenecessaryto pilethepartoftheapplicationwritteninnativeprogrammingSecond,whiletheJavaprogramminglanguageistype-safeandsecure,nativelanguagessuchasCorC++arenot.Asaresult,youmustuseextracarewhenwritingapplicationsusingtheJNI.Amisbehavingnativemethodcancorrupttheentireapplication.ForthisreasonJavaapplicationsaresubjecttosecuritychecksbeforeinvokingJNIfeatures.Asageneralrule,youshouldarchitecttheapplicationsothatnativemethodsaredefinedinasfewclassesaspossible.Thisentailsacleanerisolationbetweennativecodeandtherestoftheapplication.WhentoUsetheBeforeyouembarkonaprojectusingtheJNI,itisworthtakingastepbacktoinvestigatewhethertherearealternativesolutionsthataremoreappropriate.Asmentionedinthelastsection,applicationsthatusetheJNIhaveinherentdisadvan-tageswhencomparedwithapplicationswrittenstrictlyintheJavaprogramminglanguage.Forexample,youlosethetype-safetyguaranteeoftheJavaprogram-minglanguage.AnumberofalternativeapproachesalsoallowJavaapplicationstointeroper-atewithcodewritteninotherlanguages.Forexample:AJavaapplicationmaycommunicatewithanativeapplicationthroughaTCP/IPconnectionorthroughotherinter-processcommunication(IPC)AJavaapplicationmayconnecttoalegacydatabasethroughtheJDBC™AJavaapplicationmaytakeadvantageofdistributedobjectsuchastheJavaIDLAPI.AcommoncharacteristicofthesealternativesolutionsisthattheJavaapplica-tionandnativecoderesideindifferentprocesses(andinsomecasesondifferentmachines).Processseparationoffersanimportantbenefit.Theaddressspace6 Evolutionofthe tectionsupportedbyprocessesenablesahighdegreeoffaultisolation—acrashednativeapplicationdoesnotimmediayterminatetheJavaapplicationwithwhichitcommunicatesoverTCP/IP.Sometimes,however,youmayfinditnecessaryforaJavaapplicationtocom-municatewithnativecodethatresidesinthesameprocess.Thisiswhentheesuseful.Consider,forexample,thefollowingTheJavaAPImightnotsupportcertainhost-dependentfeaturesneededbyanapplication.Anapplicationmaywanttoperform,forexample,specialfileoperationsthatarenotsupportedbytheJavaAPI,yetitisbothcumbersomeandinefficienttomanipulatefilesthroughanotherprocess.Youmaywanttoaccessanexistingnativelibraryandarenotwillingtopayfortheoverheadofcopyingandtransmittingdataacrossdifferentprocesses.Loadingthenativelibraryinthesameprocessismuchmoreefficient.Havinganapplicationspanmultipleprocessescouldresultinunacceptablememoryfootprint.Thisistypicallytrueiftheseprocessesneedtoresideonthesame machine.Loadinganativelibraryintotheexistingprocesshostingtheapplicationrequireslesssystemresourcesthanstartinganewpro-cessandloadingthelibraryintothatprocess.Youmaywanttoimplementasmallportionoftime-criticalcodeinalower-levellanguage,suchasassembly.Ifa3D-intensiveapplicationspendsmostofitstimeingraphicsrendering,youmayfinditnecessarytowritethecorepor-tionofagraphicslibraryinassemblycodetoachieve umperformance.Insummary,usetheJNIifyourJavaapplicationmustinteroperatewithnativecodethatresidesinthesameprocess.EvolutionoftheTheneedforJavaapplicationstointeroperatewithnativecodehasbeenrecog-nizedsincetheveryearlydaysoftheJavatform.ThefirstreleaseoftheJavatform,JavaDevelopmentKit(JDK™)release1.0,includedanativemethodinterfacethatallowedJavaapplicationstocallfunctionswritteninotherlan-guagessuchasCandC++.Manythird-partyapplications,aswellastheimple-mentationoftheJavaclasslibraries(including,forexample,java.lang,java.io,and),reliedonthenativemethodinterfacetoaccessthefea-turesintheunderlyinghostenvironment.Unfortunay,thenativemethodinterfaceinJDKrelease1.0hadtwomajor7Example First,thenativecodeaccessesfieldsinobjectsasmembersofCstructures.However,theJavavirtualmachinespecificationdoesnotdefinehowobjectsarelaidoutinmemory.IfagivenJavavirtualmachineimplementationlaysoutobjectsinawayotherthanthatassumedbythenativemethodinterface,thenyouhaveto pilethenativemethodlibraries.Second,thenativemethodinterfaceinJDKrelease1.0reliesonaconserva-tivegarbagecollectorbecausenativemethodscangetholdofdirectpointerstoobjectsinthevirtualmachine.AnyvirtualmachineimplementationthatusesmoreadvancedgarbagecollectionalgorithmscannotsupportthenativemethodinterfaceinJDKrelease1.0.TheJNIwasdesignedto etheseproblems.ItisaninterfacethatcanbesupportedbyallJavavirtualmachineimplementationsonawidevarietyofhostenvironments.WiththeJNI:EachvirtualmachineimplementorcansupportalargerbodyofnativeDevelopmenttoolvendorsdonothavetodealwithdifferentkindsofnativemethodinterfaces.Mostimportantly,applicationprogrammersareabletowriteoneversionoftheirnativecodeandthisversionwillrunondifferentimplementationsoftheJavavirtualmachine.TheJNIwasfirstsupportedinJDKrelease1.1.Internally,however,JDKrelease1.1stillusesold-stylenativemethods(asinJDKrelease1.0)toimplementtheJavaAPIs.ThisisnolongerthecaseinJava2SDKrelease1.2(formerlyknownasJDKrelease1.2).Nativemethodshavebeenrewrittensothattheycon-formtotheJNIstandard.TheJNIisthenativeinterfacesupportedbyallJavavirtualmachineimple-mentati

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论