ebook img

Safe Class and Data Evolution in Large and Long-Lived Java Applications PDF

208 Pages·2001·0.8 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Safe Class and Data Evolution in Large and Long-Lived Java Applications

Safe Class and Data Evolution in Large and Long-Lived Java Applications Mikhail Dmitriev Submitted for the Degree of Doctor of Philosophy Department of Computing Science University of Glasgow March 2001 c MikhailDmitriev,May2001 (cid:13) Abstract There is a growing class of applications implemented in object-oriented languages that are large and com- plex, that exploit object persistence, and need to run uninterrupted for long periods of time. Development and maintenance of such applications can present challenges in the following interrelated areas: consis- tent and scalable evolution ofpersistent data and code, optimal build management, and runtime changes to applications. Theresearchpresentedinthisthesisaddressestheaboveissues. SinceJavaisbecomingincreasinglypopular platform forimplementinglargeandlong-lived applications, itwaschosenforexperiments. Thefirstpartoftheresearchwasundertaken inthecontextofthePJamasystem,anorthogonally persistent platform for Java. A technology that supports persistent class and object evolution for this platform was designed, builtandevaluated. Thistechnology integrates buildmanagement, persistent classevolution, and supportforseveralformsofeagerconversion ofpersistent objects. ResearchinbuildmanagementforJavahasresultedinthecreationofagenerallyapplicable, compiler-inde- pendentsmartrecompilationtechnology,whichcanbere-usedinaJavaIDE,orasastandaloneJava-specific utilitysimilartomake. The technology for eager object conversion that wedeveloped allows the developers to perform arbitrarily complex changes to persistent objects and their collections. A high level of developer’s control over the conversion process was achieved in part due to introduction of a mechanism for dynamic renaming of old classversions. Thismechanismwasimplementedusingminornon-standardextensionstotheJavalanguage. However, we also demonstrate how to achieve nearly the same results without modifying the language specification. Inthisform,webelieve, ourtechnology canbelargelyre-used withpractically anypersistent objectsolution forJava. The second part of this research was undertaken using as an implementation platform the HotSpot Java Virtual Machine (JVM), which is currently Sun’s main production JVM. A technology was developed that allows the engineers to redefine classes on-the-fly in the running VM. Our main focus was on the runtime evolution of server-type applications, though we also address modification of applications running in the debugger. UnliketheonlyothersimilarsystemforJavaknowntous,ourtechnologysupportsredefinitionof classesthathavemethodscurrently active. Severalpolicies forhandling suchmethodshavebeenproposed, oneofthemiscurrentlyoperational, anotheroneisintheexperimental stage. Wealsoproposetore-usethe runtimeevolution technology fordynamicfine-grainprofilingofapplications. i ii ABSTRACT Acknowledgements Iamgratefultothefollowingpeoplefortheirsupport, encouragement, andconstructive contributions. MalcolmAtkinson, myPhDsupervisor, fortheconstanthelpandencouragement, outstanding enthu- (cid:15) siasm and ability to generate new ideas, taking care even of my non-work circumstances, and, last butnotleast,providingthescholarship formethatcoveredbothmytuitionandlivingexpensesinthe course of my PhD. Malcolm was a head of the PJama project in Glasgow, but also played a role in theinitiating ofthe“HotSwap”project atSunLabs,onwhichIamcurrently working. Craig Hamilton, for implementing the low-level evolution and object conversion mechanisms for (cid:15) PJama, andbeingalways readytohelp. Theworkdescribed inChapter 6ofthisthesis wouldhardly becomplete without hisparticipation. Talking toCraigforalmost three years wasalso aninvaluable experience oflearningtounderstand aclassicScottishaccent. MickJordan,forprovidingthefundsandequipmentthatsupportedmeinGlasgow,andforsupporting (cid:15) myinternships atSunLabs Gilad Bracha, whowas themain initiator of the HotSwapproject atSunLabs, provided many ofthe (cid:15) ideasthataredevelopedinChapter7ofthisthesis, andwasalwayswillingtoadviseme. MarioWolczko,mymanageratSunLabs,foracceptingmefirstfortheinternship, andthenforaper- (cid:15) manentjob,givingvaluabletechnicaladvice,andconstantlyhelpingmetoresolvevariousunexpected andmysterious bureaucratic problemsarisingallbuttoooftenintheUS. Roberto Zicari, for reviewing (anonymously, of course — but a real expert can be recognised by (cid:15) the quality of his writing) and providing valuable comments to my papers, which were eventually included inthisthesis. RobertGriesemerfromJavaSoft,forhistimespentexplainingtometheinternalsoftheHotSpotJVM, (cid:15) reviewing my code and teaching me better coding habits, and kindly providing the text for Section 7.1.1ofthisthesis. LarsBak,oneofthecreatorsoftheHotSpotJVM,forgivingmetheinitialtechnicaladviceonimple- (cid:15) mentingthedynamicclassredefinition functionality. The members of the PJama group at the University of Glasgow and at Sun Labs: Greg Czajkowski, (cid:15) Laurent Dayne`s, Neal Gafter, Brian Lewis, Bernd Mathiske, Tony Printezis, and Susan Spence, for theinteresting debates, helpfuladviceandenjoyable timespenttogether overthepastthreeyears. The PJama project, within which a large part of my research was performed, was supported by a collabo- rative research grant from Sun Microsystems, Inc., and a grant from the British Engineering and Physical ScienceResearchCouncil(EPSRC). iii iv ACKNOWLEDGEMENTS Contents Abstract i Acknowledgements iii 1 Introduction 1 1.1 TheJavaProgrammingLanguage andPlatform . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Enterprise Applications, ObjectPersistence andChangeManagement . . . . . . . . . . . . 5 1.2.1 Enterprise Applications andJava . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.2.2 ObjectPersistence andJava . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.2.3 Evolution ofPersistent Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.2.4 Application Evolution andBuildManagement . . . . . . . . . . . . . . . . . . . . 8 1.2.5 RuntimeEvolution ofJavaApplications . . . . . . . . . . . . . . . . . . . . . . . . 9 1.3 ThesisStatement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.4 ThesisOverview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2 PJamaSystemandItsEvolutionModel 13 2.1 PJamaPersistentPlatform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.1.1 Orthogonal Persistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.1.2 HistoryofthePJamaProject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2.1.3 PJamaPersistence ModelOverview . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.1.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.2 Requirements forthePJamaEvolutionTechnology . . . . . . . . . . . . . . . . . . . . . . 24 2.3 MainFeaturesofthePJamaEvolution Technology . . . . . . . . . . . . . . . . . . . . . . 24 2.3.1 TheHistoryofEvolution ToolsForPJama. . . . . . . . . . . . . . . . . . . . . . . 25 2.3.2 TheFrontEnd—theopjbPersistentBuildTool . . . . . . . . . . . . . . . . . . . 27 2.3.3 SupportforOperationsontheClassHierarchy . . . . . . . . . . . . . . . . . . . . 28 2.3.4 SupportforObjectConversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2.4 PJamaEvolutionSystemArchitecture Overview . . . . . . . . . . . . . . . . . . . . . . . . 29 2.5 ThePresentConstraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.5.1 NoOn-LineorConcurrent Evolution . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.5.2 NoLazyObjectConversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.5.3 NoSupportforJavaCoreClassesEvolution . . . . . . . . . . . . . . . . . . . . . . 32 2.6 RelatedWork—OODBSystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.6.1 GeneralApproaches toChangeManagement . . . . . . . . . . . . . . . . . . . . . 33 2.6.2 TypesofChangesAllowed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.6.3 DataandCodeConsistency Preservation . . . . . . . . . . . . . . . . . . . . . . . 35 2.6.4 SupportforEvolutioninJavaBinding . . . . . . . . . . . . . . . . . . . . . . . . . 36 v vi CONTENTS 2.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 3 PersistentBuildTechnology 39 3.1 Motivation andContext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3.1.1 GeneralBuildManagement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.1.2 SmartRecompilation ofJavaApplications . . . . . . . . . . . . . . . . . . . . . . . 42 3.2 Management ofEvolvable ClassesinPJama . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3.2.1 Evolvable ClassDirectory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 3.2.2 Locating.classand.javaFilesforPersistentClasses . . . . . . . . . . . . . . . 44 3.2.3 Classeswithno.javaSources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 3.3 Persistent BuildAlgorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 3.3.1 SourceIncompatible Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 3.3.2 References inJavaBinaryClasses . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.4 RelatedWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.4.1 BuildManagement inPersistentPlatforms . . . . . . . . . . . . . . . . . . . . . . 52 3.4.2 SmartRecompilation forJava . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 3.5 FutureWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.5.1 SpeedingUpSmartRecompilation . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3.5.2 “JavaMake” Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 3.5.3 FormalProofofCompletenessandCorrectness . . . . . . . . . . . . . . . . . . . . 55 3.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 4 PersistentObjectConversion 57 4.1 WhenConversion isRequired . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 4.2 TypesofConversion: DefaultandCustom . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 4.3 DefaultConversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 4.4 CustomConversion: ClassVersionNaming . . . . . . . . . . . . . . . . . . . . . . . . . . 60 4.5 BulkCustomConversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 4.5.1 ClassModification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4.5.2 ClassDeletion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 4.5.3 Conversion forSubclasses ofEvolvingClasses . . . . . . . . . . . . . . . . . . . . 65 4.5.4 Semi-automatic CopyingofDataBetween“Old”and“New”Instances . . . . . . . 65 4.5.5 onConversionStart() andonConversionEnd() PredefinedMethods . . . . . . . 66 4.5.6 AnExample–anAirlineMaintaining a“Frequent Flyer”Programme . . . . . . . . 66 4.6 FullyControlled Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 4.7 CopyingandConversion ofStaticVariables . . . . . . . . . . . . . . . . . . . . . . . . . . 69 4.8 AccesstoNon-PublicDataFieldsandMethods . . . . . . . . . . . . . . . . . . . . . . . . 70 4.9 RelatedWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 4.9.1 JavaObjectSerialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 4.9.2 CommercialOODBMS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 4.9.3 Experimental OODBMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 4.10 FutureWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 4.10.1 Dictionary-Assisted Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 4.10.2 UsabilityAspects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 4.10.3 Concurrency andScalability Issues . . . . . . . . . . . . . . . . . . . . . . . . . . 79 4.11 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 5 Conversion CodeSemanticsandInternals 83 CONTENTS vii 5.1 Stabilityofthe“Old”ObjectGraphduring Conversion . . . . . . . . . . . . . . . . . . . . 83 5.2 LoadingClassesReferencedfromConversion Code . . . . . . . . . . . . . . . . . . . . . . 84 5.3 Programmer’sViewoftheOldClassHierarchy . . . . . . . . . . . . . . . . . . . . . . . . 86 5.3.1 UniformRenamingofOldWorldClasses . . . . . . . . . . . . . . . . . . . . . . . 86 5.3.2 Supporting theNamingArrangementforStableClasses . . . . . . . . . . . . . . . 89 5.4 Extended ImplicitTypeCasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 5.5 Implementation Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 5.5.1 FetchingClasseswithMangledNames . . . . . . . . . . . . . . . . . . . . . . . . 92 5.5.2 Implementation ofUniformRenamingofOldClasses . . . . . . . . . . . . . . . . 92 5.5.3 Management ofStableClasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 5.5.4 DealingwithMultipleClassLoaders . . . . . . . . . . . . . . . . . . . . . . . . . 95 5.6 Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 5.7 FutureWork—anAlternativeDesignInvestigation . . . . . . . . . . . . . . . . . . . . . . 97 5.7.1 ChangestoJavawiththePresentMechanism . . . . . . . . . . . . . . . . . . . . . 97 5.7.2 ASolutionThatDoesnotChangetheJavaLanguage . . . . . . . . . . . . . . . . . 98 5.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 6 Store-Level SupportforEvolution 103 6.1 SpherePersistentStoreOverview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 6.2 GoalsfortheEvolutionPlatform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 6.3 TheStore-LevelEvolutionAlgorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 6.3.1 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 6.3.2 TemporaryStorageforConvertedObjects . . . . . . . . . . . . . . . . . . . . . . . 106 6.3.3 Associating andReplacing OldandConvertedObjects . . . . . . . . . . . . . . . . 106 6.3.4 TheStore-LevelInstanceConversion Algorithm . . . . . . . . . . . . . . . . . . . 110 6.3.5 Tradeoffs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 6.4 InitialPerformance Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 6.4.1 BenchmarkOrganisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 6.4.2 TheExperimental Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 6.4.3 AReal-LifeApplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 6.4.4 RelatedWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 6.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 7 RuntimeEvolutionofJavaApplications 123 7.1 HotSpotJavaVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 7.1.1 AHistoricalNote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 7.1.2 TheFeaturesoftheHotSpotJVM . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 7.1.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 7.2 StagedImplementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 7.3 Stage1: SupportforChanging MethodBodies . . . . . . . . . . . . . . . . . . . . . . . . . 136 7.3.1 DealingwithActiveMethods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 7.3.2 Interface totheRuntimeEvolution Functionality . . . . . . . . . . . . . . . . . . . 137 7.3.3 NewClassVersionLoadingandValidation . . . . . . . . . . . . . . . . . . . . . . 139 7.3.4 ClassTransformation insidetheJVM . . . . . . . . . . . . . . . . . . . . . . . . . 140 7.3.5 Methods, EquivalentModuloConstantPool . . . . . . . . . . . . . . . . . . . . . . 143 7.3.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 7.4 Stage2: SupportforBinaryCompatibleChanges . . . . . . . . . . . . . . . . . . . . . . . 144 viii CONTENTS 7.4.1 LoadingNewClassVersions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 7.4.2 ChangeValidationandReplacement MethodDetermination . . . . . . . . . . . . . 147 7.4.3 Unregistering andRe-registering NewClasses . . . . . . . . . . . . . . . . . . . . . 148 7.4.4 SubclassExpanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 7.4.5 ClassReplacement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 7.4.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 7.5 FutureWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 7.5.1 Stage3: SupportforBinaryIncompatible Changes . . . . . . . . . . . . . . . . . . 151 7.5.2 Instance Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 7.5.3 Implementing Multiple Policies for Dealing with Active Old Methods of Changed Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 7.5.4 DynamicFine-GrainProfiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 7.6 RelatedWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 7.6.1 DynamicClassVersioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 7.6.2 Load-TimeTransformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 7.6.3 DynamicTyping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 7.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 8 Review,ConclusionsandFutureWork 161 8.1 ThesisReview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 8.2 FutureWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 8.2.1 RuntimeEvolution —WorkinProgress . . . . . . . . . . . . . . . . . . . . . . . . 163 8.2.2 DevelopmentofVMsthatSupportRuntimeEvolution . . . . . . . . . . . . . . . . 164 8.2.3 OtherDirections ofFutureWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 8.3 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 A CommandLineOptionsofthePJamaPersistentBuildTool 167 B Conversion CodeExamples 169 B.1 Version1oftheCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 B.2 Version2oftheCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 B.3 Conversion Class1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 B.4 Version3oftheCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 B.5 Conversion Class2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 C SpecificationofJVMCallsSupportingRuntimeClassEvolution 181 C.1 RedefineClasses() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 C.2 PopFrame() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Bibliography 185

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.