SlideShare une entreprise Scribd logo
1  sur  7
Télécharger pour lire hors ligne
Hacking the Source - Part I
Working with the Codename One sources is not for the faint of heart. You can learn a lot from going through the process. However, if your only goal is to avoid the build
servers you might find it harder to work with.

In fact I personally use the build servers when building apps and testing them. I almost never use offline build or the sources directly. Instead I hack and test things via
the include source options. However, learning this is still valuable and I'm aware of a few people who don't share my opinion on this matter...
Who is this For?
© Codename One 2017 all rights reserved
✦You like doing everything manually
✦You want to learn low level underpinnings
✦Future proofing
Still, why would I write a guide for something like this?

There are 3 individuals I can think of who might benefit from this guide

If you are the type of person who needs to do everything yourself then this is pretty much it

If you want to understand the underpinning of Codename One at a deeper level than the more abstract descriptions. Then this is a good first step

If you want to feel secure that you can hack Codename One manually if our service changes or becomes unavailable in the future then the mere existence of this guide
should help calm some of those concerns
Basics
© Codename One 2017 all rights reserved
✦VM
✦API
✦Ports
To understand how to work with the Codename One code we first need to understand what Codename One does. For this case I'll remove the build servers from the
equation and focus on the portability aspect.

Codename One includes 3 distinct pieces for portability: 

VM - for some platforms such as Android the VM is natively included. However, we work on top of ParparVM in iOS, iKVM in Windows & TeaVM for JavaScript

API represents the actual calls to the com.codename1 classes



Ports are the implementations of the API for the various platforms

This is all pretty trivial. The API is always the same, we change the VM and ports to support all the platforms. So if you understand this then the simulator is simple too. In
the simulator the VM is just the standard Java VM. And the port is just a port of Codename One to JavaSE. 

There is a bit more to that though. The port to JavaSE includes a lot of specialized glue code to show the simulator and other features such as the network monitor etc.

But lets start with this and move on.
Plugin & Tools
© Codename One 2017 all rights reserved
✦You don’t need the plugin for this module
✦But it will make things easier
✦JDK 8 (not newer)
✦Apache Ant
✦Git
✦Android Studio 3.x
✦xcode 9.x
All of the instructions that follow will work regardless of whether you have the plugin installed. I will focus on using the command line and assume that you can translate
that to your IDE of choice.

Technically you don't really need the plugin if you are working from the source code. However, it's convenient to work with. It means that selecting New Project and
picking Codename One “just works”. It means that double clicking a resource file launches the designer tool. But technically you don't really need it.

What you do need is JDK 8 notice that newer versions might not work! We generally use the Oracle JDK because it comes bundled with JavaFX and that makes
everything simpler as the simulator needs JavaFX for some features (specifically media and browser). If you choose to use Open JDK it might work if you install it with
OpenJFX but it's not something we tried.

Apache Ant can be downloaded from the Apache website. Make sure ant is in your system path and that the command runs. Note that you will need to define the
JAVA_HOME environment variable properly.

Git is optional. You can just download the zip from github but if you'd like to contribute pull requests back into the project this can be useful.

For Android development we’ll use Android Studio 3.x which you can download from Google

For iOS development we will use xcode 9.x from Apple
git clone https://github.com/codenameone/CodenameOne.git cn1
git clone https://github.com/codenameone/cn1-binaries.git
git clone https://github.com/codenameone/codenameone-skins.git
or download:
https://github.com/codenameone/CodenameOne/archive/master.zip
https://github.com/codenameone/cn1-binaries/archive/master.zip
https://github.com/codenameone/codenameone-skins/archive/master.zip
The Code
We need to clone these repositories or just download the source zips of these repositories and expand them. These repositories should reside in the same hierarchy and I
will rely on that later on when giving out instructions. 

you will notice we have 3 repositories to start with. Codename One is the main repo, the skins make sense as we use them to show the phone skins. But why have
binaries?
Binaries
© Codename One 2017 all rights reserved
✦svg
✦ikvm.zip
✦rim5/rim4
✦jfxrt.jar
✦javase/Filters.jar
✦javase/sqlite*
✦vm/asm*
✦android
✦j2me
✦designer
✦JavaDocSourceEmbed.jar
✦CLDC11.jar
✦corevm.jar
✦uwp
The immediate question would be why do we need binaries for an open source project?

The answer is that they are harder to build on their own in some cases and in others we need stubs of native platforms so we can compile against them without
downloading the full SDK. Lets go over the files & directories in the binaries project and explain them one by one:

The svg directoryis from the open source Batik project. It's unmodified. We need it for the Designer tool for SVG support.

The iKVM project is hard to compile without windows so we have a pre-compiled version here.

These are legacy stubs of the blackberry OS I won't cover blackberry here so these aren't really needed.

We need stubs to compile JavaFX code we don't embed this

This is the jhlabs project for Java SE image filters. We use this to implement gaussian blur in the simulator

These are used by the SQLite implementation in the simulator

these are a part of the open source ASM project which we use in ParparVM

Everything here is stubs which we use to compile the Android native implementation without downloading the full Android SDK. We don't run any of this just use it for
compilation
cn1 Directory Sources
© Codename One 2017 all rights reserved
✦CodenameOne
✦CodenameOneDesigner
✦vm
✓ ByteCodeTranslator
✓ JavaAPI
✦Factory
✦Themes
✦tests
✦Ports
✓ Android
✓ iOSPort
✓ JavaSE
✓ UWP
✓ CLDC11
✓ retro/rim/j2me/
winphone7
Before we go into building the project lets inspect the separate pieces. Most of the pieces we fetched in the Codename One repository are NetBeans projects. Notice
that NetBeans projects are just specific folder structures with an Ant build.xml file. That means you don't need NetBeans in order to build or run them. 

The CodenameOne folder includes the Codename One API's. This is just a standard NetBeans ant project that contains 100% portable code. Notice that at this time this
project still uses Java 5 syntax due to some technical constraints.

CodenameOneDesigner contains the designer tool which is a Swing application built with the Swing App Framework. It's a standard NetBeans project too with major
pieces written using the NetBeans Matisse GUI builder.

The VM directory hosts the ParparVM source code. It includes two sub folders each of which is a standalone NetBeans ant project

The BytecodeTranslator is a Java NetBeans project that reads Java bytecode and generates C code. It includes a couple of builtin C files but most of the C code is
generated

The portion of the VM that isn't a part of the Codename One API. This is a NetBeans project that includes implementations of all the java packages needed by ParparVM

Factory is a simple project that contains one class com.codename1.impl.ImplementationFactory. That lets us decouple the implementation of Codename One from the
ports

Themes are the native OS theme files which we load when a theme derives from native. These are embedded into the ports and into the skins

Contenu connexe

Similaire à Hacking the Codename One Source Code - Part I - Transcript.pdf

How to add ar effects to an android app using vr face library
How to add ar effects to an android app using vr face library How to add ar effects to an android app using vr face library
How to add ar effects to an android app using vr face library Moon Technolabs Pvt. Ltd.
 
How do I - Use Include Source to debug native code - Trasnscript.pdf
How do I - Use Include Source to debug native code - Trasnscript.pdfHow do I - Use Include Source to debug native code - Trasnscript.pdf
How do I - Use Include Source to debug native code - Trasnscript.pdfShaiAlmog1
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notesWE-IT TUTORIALS
 
198970820 p-oooooooooo
198970820 p-oooooooooo198970820 p-oooooooooo
198970820 p-oooooooooohomeworkping4
 
SE2018_Lec-22_-Continuous-Integration-Tools
SE2018_Lec-22_-Continuous-Integration-ToolsSE2018_Lec-22_-Continuous-Integration-Tools
SE2018_Lec-22_-Continuous-Integration-ToolsAmr E. Mohamed
 
2012 04-19 theory-of_operation
2012 04-19 theory-of_operation2012 04-19 theory-of_operation
2012 04-19 theory-of_operationbobwolff68
 
Workflow for Development, Release and Versioning with OSGi / bndtools- Real W...
Workflow for Development, Release and Versioning with OSGi / bndtools- Real W...Workflow for Development, Release and Versioning with OSGi / bndtools- Real W...
Workflow for Development, Release and Versioning with OSGi / bndtools- Real W...mfrancis
 
Top Java Development Tools To Use In 2023
Top Java Development Tools To Use In 2023Top Java Development Tools To Use In 2023
Top Java Development Tools To Use In 2023SofiaCarter4
 
Google ART (Android RunTime)
Google ART (Android RunTime)Google ART (Android RunTime)
Google ART (Android RunTime)Niraj Solanke
 
The Development History of PVS-Studio for Linux
The Development History of PVS-Studio for LinuxThe Development History of PVS-Studio for Linux
The Development History of PVS-Studio for LinuxPVS-Studio
 
Node.js vs. java which one should you choose for backend development
Node.js vs. java  which one should you choose for backend development Node.js vs. java  which one should you choose for backend development
Node.js vs. java which one should you choose for backend development Moon Technolabs Pvt. Ltd.
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuningJerry Kurian
 
Django simplified : by weever mbakaya
Django simplified : by weever mbakayaDjango simplified : by weever mbakaya
Django simplified : by weever mbakayaMbakaya Kwatukha
 
Makefile
MakefileMakefile
MakefileIonela
 
10 interesting things about java
10 interesting things about java10 interesting things about java
10 interesting things about javakanchanmahajan23
 

Similaire à Hacking the Codename One Source Code - Part I - Transcript.pdf (20)

How to add ar effects to an android app using vr face library
How to add ar effects to an android app using vr face library How to add ar effects to an android app using vr face library
How to add ar effects to an android app using vr face library
 
The Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.NetThe Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.Net
 
How do I - Use Include Source to debug native code - Trasnscript.pdf
How do I - Use Include Source to debug native code - Trasnscript.pdfHow do I - Use Include Source to debug native code - Trasnscript.pdf
How do I - Use Include Source to debug native code - Trasnscript.pdf
 
tybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notestybsc it asp.net full unit 1,2,3,4,5,6 notes
tybsc it asp.net full unit 1,2,3,4,5,6 notes
 
198970820 p-oooooooooo
198970820 p-oooooooooo198970820 p-oooooooooo
198970820 p-oooooooooo
 
SE2018_Lec-22_-Continuous-Integration-Tools
SE2018_Lec-22_-Continuous-Integration-ToolsSE2018_Lec-22_-Continuous-Integration-Tools
SE2018_Lec-22_-Continuous-Integration-Tools
 
2012 04-19 theory-of_operation
2012 04-19 theory-of_operation2012 04-19 theory-of_operation
2012 04-19 theory-of_operation
 
Workflow for Development, Release and Versioning with OSGi / bndtools- Real W...
Workflow for Development, Release and Versioning with OSGi / bndtools- Real W...Workflow for Development, Release and Versioning with OSGi / bndtools- Real W...
Workflow for Development, Release and Versioning with OSGi / bndtools- Real W...
 
Developers survival-guide
Developers survival-guideDevelopers survival-guide
Developers survival-guide
 
Top Java Development Tools To Use In 2023
Top Java Development Tools To Use In 2023Top Java Development Tools To Use In 2023
Top Java Development Tools To Use In 2023
 
Google ART (Android RunTime)
Google ART (Android RunTime)Google ART (Android RunTime)
Google ART (Android RunTime)
 
The Development History of PVS-Studio for Linux
The Development History of PVS-Studio for LinuxThe Development History of PVS-Studio for Linux
The Development History of PVS-Studio for Linux
 
Node.js vs. java which one should you choose for backend development
Node.js vs. java  which one should you choose for backend development Node.js vs. java  which one should you choose for backend development
Node.js vs. java which one should you choose for backend development
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
Django simplified : by weever mbakaya
Django simplified : by weever mbakayaDjango simplified : by weever mbakaya
Django simplified : by weever mbakaya
 
Makefile
MakefileMakefile
Makefile
 
109842496 jni
109842496 jni109842496 jni
109842496 jni
 
Intro to Github
Intro to GithubIntro to Github
Intro to Github
 
Lamp Zend Security
Lamp Zend SecurityLamp Zend Security
Lamp Zend Security
 
10 interesting things about java
10 interesting things about java10 interesting things about java
10 interesting things about java
 

Plus de ShaiAlmog1

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...ShaiAlmog1
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfShaiAlmog1
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfShaiAlmog1
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfShaiAlmog1
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfShaiAlmog1
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfShaiAlmog1
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfShaiAlmog1
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfShaiAlmog1
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfShaiAlmog1
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfShaiAlmog1
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfShaiAlmog1
 

Plus de ShaiAlmog1 (20)

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdf
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdf
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdf
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdf
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdf
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
 

Dernier

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Hacking the Codename One Source Code - Part I - Transcript.pdf

  • 1. Hacking the Source - Part I Working with the Codename One sources is not for the faint of heart. You can learn a lot from going through the process. However, if your only goal is to avoid the build servers you might find it harder to work with. In fact I personally use the build servers when building apps and testing them. I almost never use offline build or the sources directly. Instead I hack and test things via the include source options. However, learning this is still valuable and I'm aware of a few people who don't share my opinion on this matter...
  • 2. Who is this For? © Codename One 2017 all rights reserved ✦You like doing everything manually ✦You want to learn low level underpinnings ✦Future proofing Still, why would I write a guide for something like this? There are 3 individuals I can think of who might benefit from this guide If you are the type of person who needs to do everything yourself then this is pretty much it If you want to understand the underpinning of Codename One at a deeper level than the more abstract descriptions. Then this is a good first step If you want to feel secure that you can hack Codename One manually if our service changes or becomes unavailable in the future then the mere existence of this guide should help calm some of those concerns
  • 3. Basics © Codename One 2017 all rights reserved ✦VM ✦API ✦Ports To understand how to work with the Codename One code we first need to understand what Codename One does. For this case I'll remove the build servers from the equation and focus on the portability aspect. Codename One includes 3 distinct pieces for portability: 
 VM - for some platforms such as Android the VM is natively included. However, we work on top of ParparVM in iOS, iKVM in Windows & TeaVM for JavaScript API represents the actual calls to the com.codename1 classes
 
 Ports are the implementations of the API for the various platforms This is all pretty trivial. The API is always the same, we change the VM and ports to support all the platforms. So if you understand this then the simulator is simple too. In the simulator the VM is just the standard Java VM. And the port is just a port of Codename One to JavaSE. There is a bit more to that though. The port to JavaSE includes a lot of specialized glue code to show the simulator and other features such as the network monitor etc. But lets start with this and move on.
  • 4. Plugin & Tools © Codename One 2017 all rights reserved ✦You don’t need the plugin for this module ✦But it will make things easier ✦JDK 8 (not newer) ✦Apache Ant ✦Git ✦Android Studio 3.x ✦xcode 9.x All of the instructions that follow will work regardless of whether you have the plugin installed. I will focus on using the command line and assume that you can translate that to your IDE of choice. Technically you don't really need the plugin if you are working from the source code. However, it's convenient to work with. It means that selecting New Project and picking Codename One “just works”. It means that double clicking a resource file launches the designer tool. But technically you don't really need it. What you do need is JDK 8 notice that newer versions might not work! We generally use the Oracle JDK because it comes bundled with JavaFX and that makes everything simpler as the simulator needs JavaFX for some features (specifically media and browser). If you choose to use Open JDK it might work if you install it with OpenJFX but it's not something we tried. Apache Ant can be downloaded from the Apache website. Make sure ant is in your system path and that the command runs. Note that you will need to define the JAVA_HOME environment variable properly. Git is optional. You can just download the zip from github but if you'd like to contribute pull requests back into the project this can be useful. For Android development we’ll use Android Studio 3.x which you can download from Google For iOS development we will use xcode 9.x from Apple
  • 5. git clone https://github.com/codenameone/CodenameOne.git cn1 git clone https://github.com/codenameone/cn1-binaries.git git clone https://github.com/codenameone/codenameone-skins.git or download: https://github.com/codenameone/CodenameOne/archive/master.zip https://github.com/codenameone/cn1-binaries/archive/master.zip https://github.com/codenameone/codenameone-skins/archive/master.zip The Code We need to clone these repositories or just download the source zips of these repositories and expand them. These repositories should reside in the same hierarchy and I will rely on that later on when giving out instructions. 
 you will notice we have 3 repositories to start with. Codename One is the main repo, the skins make sense as we use them to show the phone skins. But why have binaries?
  • 6. Binaries © Codename One 2017 all rights reserved ✦svg ✦ikvm.zip ✦rim5/rim4 ✦jfxrt.jar ✦javase/Filters.jar ✦javase/sqlite* ✦vm/asm* ✦android ✦j2me ✦designer ✦JavaDocSourceEmbed.jar ✦CLDC11.jar ✦corevm.jar ✦uwp The immediate question would be why do we need binaries for an open source project? The answer is that they are harder to build on their own in some cases and in others we need stubs of native platforms so we can compile against them without downloading the full SDK. Lets go over the files & directories in the binaries project and explain them one by one:
 The svg directoryis from the open source Batik project. It's unmodified. We need it for the Designer tool for SVG support. The iKVM project is hard to compile without windows so we have a pre-compiled version here. These are legacy stubs of the blackberry OS I won't cover blackberry here so these aren't really needed. We need stubs to compile JavaFX code we don't embed this This is the jhlabs project for Java SE image filters. We use this to implement gaussian blur in the simulator These are used by the SQLite implementation in the simulator these are a part of the open source ASM project which we use in ParparVM Everything here is stubs which we use to compile the Android native implementation without downloading the full Android SDK. We don't run any of this just use it for compilation
  • 7. cn1 Directory Sources © Codename One 2017 all rights reserved ✦CodenameOne ✦CodenameOneDesigner ✦vm ✓ ByteCodeTranslator ✓ JavaAPI ✦Factory ✦Themes ✦tests ✦Ports ✓ Android ✓ iOSPort ✓ JavaSE ✓ UWP ✓ CLDC11 ✓ retro/rim/j2me/ winphone7 Before we go into building the project lets inspect the separate pieces. Most of the pieces we fetched in the Codename One repository are NetBeans projects. Notice that NetBeans projects are just specific folder structures with an Ant build.xml file. That means you don't need NetBeans in order to build or run them. The CodenameOne folder includes the Codename One API's. This is just a standard NetBeans ant project that contains 100% portable code. Notice that at this time this project still uses Java 5 syntax due to some technical constraints. CodenameOneDesigner contains the designer tool which is a Swing application built with the Swing App Framework. It's a standard NetBeans project too with major pieces written using the NetBeans Matisse GUI builder. The VM directory hosts the ParparVM source code. It includes two sub folders each of which is a standalone NetBeans ant project The BytecodeTranslator is a Java NetBeans project that reads Java bytecode and generates C code. It includes a couple of builtin C files but most of the C code is generated The portion of the VM that isn't a part of the Codename One API. This is a NetBeans project that includes implementations of all the java packages needed by ParparVM Factory is a simple project that contains one class com.codename1.impl.ImplementationFactory. That lets us decouple the implementation of Codename One from the ports Themes are the native OS theme files which we load when a theme derives from native. These are embedded into the ports and into the skins