---
title: WWDC2000 Session 408
framework: wwdc
role: article
path: wwdc/wwdc2000-408
---

# WWDC2000 Session 408

## Transcript

Kind: captions Language: en this is going to be a fun one talking about to see to Java transition issues so please give your undivided attention to France as well hi nice to meet you all today and she's going to be the most support hour of the day so bear with me and we'll make it exciting I know there are a lot of objective-c villas this afternoon in the room and I am a show of hand oh yeah so don't worry I brought the bulletproof vest throughout the show and let me introduce my bodyguard BAM tremble yes and we have riot shield in the back so and then by the way will be doing the demo for us today okay so what are we going to cover this session is going to assume some previous knowledge of web objects obviously if you've been programming for using advocacy you know about web objects and we are going to cover the different strategies for converting objective-c wet crip and with Java projects and we are going to demo all supplied conversion tools what you'll know learn will first make a stop and go back on the goals of the pure Java which is named web objects 5 we then going detail into who should convert who should not and what API on feature changes you can expect in web objects pure Java then we'll move into the conversion process per se and give you some hints on how you can expand it so what is this web of x-5 relieves called web as x5 for Java I never understand why there is for that after once because in Java anyway so it is basically whether X 4.5 water to Java it is a huge full-featured web as X 0.5 comply I am and all the framework web objects gof work extensions you name it other it works as an add-on to web objects 4.5 for example all the developer tools are shared between 4.5 and web of x5 the monitoring tools have been ported and the test tools have been ported as well so that you can use them you can use the pure Java version of these tools to either monitor or test the 4.5 apps all the high point OS this is a good way for us to provide both fixes for these tools in the at the same time and finally there is the conversion tool we are going to talk about today so what are the benefits what one of the most important benefits that is still one where we used to run you can still develop a Mac os10 server on Windows and soon you'll be able to develop a Mac os10 the deployment platforms I've been extended and we window support Linux deployment environment we accept to have a smaller runtime footprint by by moving to Java and to let you deploy on a lot of different platforms that we can even think of we're looking forward some when deploying on PlayStation for example I don't even know if there'll be employed other benefits well you can expect and take my word for it a better Java experience web project 5.0 is going to run on JDK one one eight by by default and will be dedicated to an 1.3 compliant we are not going to take advantage of the newer VMs but just for backward compatibility but we are going to run on them this release with a low for much better integration with third-party development tools we have already some experience using optimizers and debuggers that are outside or usual on tools box and finally we will integrate much better with any third party products that provides a Java interface no more bridge issue to be concerned about so more benefit the database connectivity is going to be extended now that we have a pure JDBC support we are as well providing a plug-in technology so that for vendors that have a customized ad BC interface we are able to support this customization we have as well ported the LDAP adapter okay so when I showed marketing the prototype of the web of x-5 release which was codenamed mone at the time from the French painter they came to me and said well France as it is great but what are we going to do with all our Objective C developers that have and rather saddled of lines of code are you going to provide them a tool to deal with this and I said no way I cannot do it this is a test that is very hard and will never reach a hundred percent solution but I I went for it and I spent some time designing and spend a lot of time in the dark then I saw the light and I really came up with a very good design for the for a Java converter and my claim is that we are going to take you 80% toward the pure Java solution by using these tools and by the way there will be a jar converter t-shirt and guess what will be at the back of the dryer converter t-shirt we will have commented out ok let's move on we should convert well basically any of the key via web Script developer that requires more deployment solution should consider converting anyone with an existing with java application should not even consider it you just do it because it's going to be seamless and anyone requiring access to modular standards to better Java development tools that we do not provide should think about converting to we should think twice up before converting well if you've been around for a long time you have been used to take advantage of the objective-c goodies that we like and that we are going to lose so if your web address application or framework contains tons of categories on your own NS star roaster or co-star classes maybe because you want to extend them maybe because you want to fix or own bugs you name it well you're going to be in trouble if you rely heavily on the PO - feature for the same reasons both as is a very powerful feature of objectives of objective-c and it is good if you use a lot of low-level of the different time calls this kind of function that you can find in the system that framework headers - objective-c header files these are all not supported we have to deal with the pure Java runtimes runtime provided by the DDT and the reflect api's if you use low level c function calls or structures you're in trouble again you'll have to change these structures into objects if you can but if you don't own this CC function calls while you'll have to find an equivalent in Java and of course if you're already in production with your application it is in Objective C but you have deployed it why the hell would you want to convert just let it burn let it bring you money by truckload and concentrate on the future the conversion process so what what does it take so my claim again it will take you 80% there let's use the metaphor here let's assume you want to repaint your house so you could go for a go at it with a paintbrush on the bucket of pay don't spend your summer paint in your house well that's not very exciting now the other solution is to hire professional the professionals are very expensive we're in the 21st century so you could have higher army of robots that would come and because they are very basic robots that would tape around the trimming and windows of your house on sprayed spray-painted now they would pay a few bushes on trees but what the heck your house is painted and you're 80% their hole is left for you is to remove the table do the finish work it's the interesting work that's all the rock converter works ok let's start with a demo so then my lovely assistant of the day will they were the data conversion on one of your example the distributed session store application so basically this is a command line tool that is written in Java and you see that it is first copying the project and then moving through all the files this is fast default so it's really hard to talk as fast sorry for the Japanese translator okay did the job now if Ben would like to open the project this was a project with some web script and some on one dot M so it's a very simple project then you want to open the Java version which is one of these yeah so open the PDF project so you'll see that no you just have Java classes and the same application that I'm was changing to an application to Java you can click on it to show that there is some data code there and same with the same with the other classes if you look at the framework bucket the framework bucket is now pointing to the new frameworks and so on so I wouldn't claim that this code compile but for the grunt work is done now we have another example which is again doing the same kind of work but this time on this file the file we take is the eeo utilities file so open G and pickier utility dot M yes so again the convertor is working on the file and is going to come out with okay so at one point you see that there are some possible post-processing calls being done it's part of the customization I took and I will explain it in more detail later on now if you look at the file that have been created for us can you sing yet click again unlike in the scientist and click on OK they are here so you have two files one one year into the Java which is actually I believe empty because most of these click on it it should be okay movies ok click on this one here this one is interesting so this is actually what happens to categories categories are moved to static classes you don't see the word static here this is a bug but basically the methods that were in editing context here it is on a editing contacts are no move to categories and this is the important point ok and now as a last demo gee the demo that is going to take much longer Ben is going to start in the background with the conversion of the you all go extensions framework so it is a five thousand lines of code freaking framework with of the kisi web script Java isn't a client-side driver and it's just going to go through it so this is going to take a while let's move back to the slide now and I'm Ben tell us when she's finished that we can look at the result okay so what did you see the other converter has different load of functioning it has the project white conversion mode the file by file conversion mode for touch up work and then all at once or which data only conversion mode so what are the different tests you can accomplish you can first move your files one by one from COTC or web script to pure a pure data file you can move a wool project directory to a huge elaborate directory you can move a product directory to an intermediate step which is with Java which you can still run on for five and then move it again to a pure Java project directory and you could do the same with files so why would you convert in one step converting in one step from an objective-c to a pure Java project can be done for smaller projects you can expect a long period of non running right I'm just being objective and all your files are converted and the resources that make files and the framework references are corrected we need to slightly modify the component word files and the director web model for example now by the way this looks vanitas try again by the way it is one step procedure is the one we took for or ill access layer Oh you access framework the two steps conversion is a procedure I followed for the web objects framework itself at the time I didn't have a conversion tool it came after one so I add the I did the 2037 line by hand and it was at a pleasurable experience the way I made it more pleasurable was by 14 classes five classes one after the other and keeping the app running at all time so this is doable thanks to the bridge you can we recommend this approach for other projects because at all time you keep your project running you're just moving one file at a time from the objective-c world to the bridge Java world and you keep everything in sync you make some API public a throw of rappers by doing so you can do incremental framework conversion and you can go down to a class-by-class conversion when I started converting WebLogic to Java I was wasn't even sure it was going to work in the first place so what did I do I started by converting the dynamic elements and pretty soon I had a framework that was split between objective-c bridge Java and I was applying a tiny to an example like hello world and it was still working so I got I grew more confident and I sorted the whole session object now I had a void session object on the bridge side on and so on and so on until one day all I had left was the application object now this object is the five thousand line of code monster again here there is another approach you can take which is to subclass this Objective C Java so class exclusive reached in bridge Java and at this point you can move method per method one by one through the bridge and again makes the conversion process much more stable I'd say you you and you always have something running it takes a lot more time but if you have a manager breathing down your neck asking you well what Francois what where are you today you can say well today as I have the position that he's running or whatever is your case and once running your project can be converted to pure Java by using the Java convert or I guess I guess ok so what does the result include that I could look like well let's let's pause for a moment how do I look like now I look like a clown hey I'm still myself yeah I do look like a clown but I am still myself and your code is still going to be your code is going to look different but the important part of the logic the algorithms are still there and they are still yours so please look further than just the language are in because this language conversion can be automated what cannot be automated is the value you bring in the code which is your own logic and what we do is that we beautify your code well beautify to which standard I'm a metal person and I don't care very much about aesthetics but we have some people in all groups that are very on top of this these code standards and the way they are defined or beautified code stand down well if you don't like them use one of these beautifier that are available on the web for Java code so about ten of them so pick your own and make it look as you want now we preserve the order in your code of course otherwise what would be left and we provide all your comments we as well add some comments that are tagged so that you get three more three levels of conversion error that are easily searchable in the produced Java code we're done principle Wow what timing okay so let's look at the or extensions java project so this is a very big project with sub project and the Java converter dealt with them correctly if you move to the oh here actually we have some more category interesting category categories on objects that are not recognized like NS RA in a suitable array cannot be merged back into the model class let's say so these categories are transformed into static classes these are the four ones you see at the beginning of the product class list now if you move to sub projects for example or you would like to see one okay click on the first one for example so it's now a helper class and I and this method should actually be static this is just a bug will fix now if you move to the sub-project bucket you see that we had a bunch of sub product we had client-side Java code whereas it was QR code and we just didn't touch it because it was already in future we add some more for example examples of or even oh let the war events login code is interesting as well very complicated code can you open one of these let's see see what you can we can find here so you see the comments of reserved them yeah it's not very complicated so this kind of classes we can expect you can expect them to compile at one let's move back to the top level I'd like to show a wedge click file subclasses and look for the statistics page I know this was a web script but fine was that stage okay so far was that for four wet script files basically what you lose whenever whenever you add Ivar declarations with the ID tag what you lose is what you won't get is a type declaration of the object so for all the divers you get an object type and whenever we can restore the type we do for example you see here in the middle are immutable dictionary and double well the Java converter is clever enough to notice that some operation some arithmetic operation was done on this either so it deducted that this should be a double so it made it a double either instead of a just a plain object so sometimes with web script it's able to restore the type of an object other times it will just eat it as an object okay well let's switch back to the slide and let's move on so once it is time to compile you go through all these arrows and pull them one by one and we go because most of the arrows will be the same you're going to be able to solve them so bunch of them at a time and more importantly have a consistent way of solving them so the biggest problem I got when I did my file by file conversion converting the web objects framework was that I a month down the road I had forgotten what type of solution I had found for a problem on day one and I tend to solve same problems in different ways and it gets very inconsistent coding now when you have a tool that we do everything upfront for you it was so simple problems like try catch exception wrapping of exceptions and enumerations and so on in a nice and consistent way so actually in that you know 80 percenter and that i have taken out the hassle of converting my translation translation rate personally was trained with lines a day so for example this project of work extensions that seat 45 hundred lines of code code I would have done in 15 days Java converter just did it just brought the 80 percenter in five minutes so that's a pretty good accomplishment isn't it okay let's let's drill down more into the issues some foundation classes are not available anymore so don't run away screaming these are the classes you are not choosing the first place or you are using them because you had to like any photo release pool who is going to monitor release pool we have some skeptics and some masochist here java.lang thread is a good alternative to an a thread same with java.lang string so we remove the next thread in a string on others that had exact counterpart in the Java world the NS stars structs are gone except NS range we get an S range because it was used in a public API and we didn't want to break away a week API so we keep kept it but if you're using NS size and this point and expect you'll have to create your own Java object to do so category issues so let's let's sum up what we saw in the demonstration categories on classes in the same project are reunited so if you have your own you implement your own class and then lower down in a sub-project you stop adding categories on on this class well everything will be merged in one class so you will not be able to use category two compartment your code anymore like in Objective C categories on external classes are transformed in helper class especially categories on classes like any string but the new l4 classes cannot be referenced when needed automatically so you will still have to go back let's say let's say your decide to have a categorical and a string on we implement length now we are going to put a dollar converter is going to create for you Minister NS string and overall length class will help with the help from s current length but it's not going to be able to guess every that everywhere in your code it would call length or not so you will have to go and modify the static so call into a static holder macros and functions all macros are resolves this is done by using the pre compiler and because of that you may run to problem if you ever if you are using if there's a lot to do software platform issues you may have to convert several times for every platform you're using exception handling is handled nicely and it's enumeration numerator and of nicely as well same with if statement where the weather node is no test if the object is null or not all the NS functions call our God and these are automatically translated when we can in other cases we do not have an equivalent so you'll be on your own on your own and finally see function calls must be corrected manually we do not provide a conversion comment for assortment for example the more API issues most of our API changes are automatically done for you and for from most of these API changes out actually occur between objective-c Umbra Java between grid Java on geogebra there is almost no API change the API chain is a change between bridge around pure Java is just an import statement change and a couple of reactions that's very minimal so don't be too concerned about this the API you're using 95% of the time will be there so as I said all classes are kept there bridge the API and the API changes on your framework can be automated I will explain a go more into detail on this last point later ok now what happens when you start an objective-c conversion basically the jar converter is an objective-c compiler it's written in pure Java as well but and because of that furnace you cannot use the new objective-c grammar it's using a grammar that I have rewritten that is based on the on the globe rikishi grammar and it follows a grandmaster dog from meta meta which is a grammar used across java as a java world for parsing and we provided Granoff so that you can improve it if you if you want to support weird objective-c syntax like at ASM for assembly code if you find a way to embed assembly code in your java programmer you can use a ram or you can do that this is not a good C compiler I have concentrated on converting objective-c to Java and not C to Java if you rely a lot on the C pointers and pointer manipulation well you're going to be in trouble so don't use that to convert your your C Bay graphics library Network and as I said before we use CPP for macro pre-processing web script font conversion well what is the bank Wesley Prosser we have here its web script itself so I made I'm slightly modified the west whipped butter and extended it to generate pseudo objective-c so once I get this to double active C code I can feed it to the real Java converter that will change it into Java code that's basically all it works so I had to loosen somewhat the objective-c growl ah so that it would accept it slack of the keep C web script coding standards that you like and finally the bridge Java conversion is done by just feeding a bridge Java file to a sub script and the output is pure Java all the imports are corrected the minimize minimal API changes are applied and that's it Java converter is extensible why does it mean as I said before this well I haven't said it before but the source code will be provided the grammar will be provided and for people that are not that adventurous we will we as well provide Burkittsville script folders where you can drop your own script to enhance the pre and post conversion steps so if you have put a script in the pre-conversion folder whatever file is fed to the java converter first we pass with this script and the output will only be fed to the data converter and this way you can automate your own framework API changes if you have your own API changes between Objective C to Java on you most likely will you can automate them with one of these quick conclusion I went into more detail in the Weber's x5 and our environment we demoed you a great tool that handles much of the uninteresting work for converting Java code elective C code to Java and it will be available to you in the upcoming beta so I hope I hope most of you will find a use for it and that you will be very successful now if you have any question you should we will have both meeting both of the feder later today across carry across the street yes and now I want you to think different about the conversion process and I will take any questions right thank you very much [Applause] you
