资源描述:
《yet another java.lang.class》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、YetAnotherjava.lang.ClassShigeruChibaMichiakiTatsuboriInstituteofInformationScienceandElectronicsUniversityofTsukuba1-1-1Tennodai,Tsukuba,Ibaraki305-8573,Japan.Phone:+81-298-53-5349Fax:+81-298-53-5206E-mail:chiba@is.tsukuba.ac.jp1IntroductionTheJavalanguagealreadyhas
2、theabilityforre
ection[2,4].java.lang.Classisaclassforclassmetaobjectsandprovidestheabilityforintrospectionatruntime.Atruntime,theJavaprogrammerscaninspectvariousinforma-tion,forexample,theclassofagivenobject,whichmethodsthatclasshas,andsoforth.Theycanalsogetthevalue
3、ofaeldandinvokeamethodspeciedbyacharacterstring.Forexample,theymaywritethefollowingcode:Personp=newPerson("Joe");Classc=p.getClass();Fieldf=c.getField("name");//theeldnameisavariableStringname=(String)f.get(p);//sameasStringname=p.name;However,theJavalanguagehasno
4、tprovidedtheabilityforlanguagecustomization,orintercession,whichisanotherkindofre
ection.TheJavaprogrammerscannotchangethesuperclassofaclass,alterthebehaviorofmethodinvocation,orextendthesyntax.AfewextensionstoJava,suchasMetaJava[3],havebeenproposedtosupporttheabilit
5、yforlanguagecustomization,buttheirabilitiesarelimitedtocustomizationsthatdonotimplysevereperformanceimpacts.Thispaperproposesanextendedversionofjava.lang.Class,whichenablesmorecomprehensivelanguagecustomizationthanothersimilarsys-tems.Toavoidperformancedegradation,we
6、employatechniquecalledcompile-timere
ection.MostofcustomizationsarestaticallyappliedtoaJavaprogramatcompiletimeandthecompiledcodeisexecutedbytheregularJavavirtualmachine(JVM)withalmostnoperformanceoverheads.1Intherestofthispaper,werstmentionrequirementsfortheability
7、forlanguagecustomization.ThenweoverviewtheproposedextensiontoJava'sre
ectionmechanism.2RequirementsforcustomizabilityFirstofall,webrie
ysummarizethekindsoflanguagecustomizationthatweshouldbeabletoperforminJavabytheextendedre
ectionmechanism.Thesecustomizationsarecons
8、iderablyusefulinpracticeaccordingtoourexperiencewithOpenC++[1].TocustomizethestructureofaclassThere
ectionmechanismshouldallowtheme