SlideShare a Scribd company logo
1 of 7
Download to read offline
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

More Related Content

Similar to Hacking the Codename One Source Code

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
 

Similar to Hacking the Codename One Source Code (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
 

More from 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
 

More from 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
 

Recently uploaded

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Hacking the Codename One Source Code

  • 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