230 likes | 369 Vues
Femto Java Developing Java applications for tiny footprint platforms. Eduard de Jong QC Technology B.V. BOF 2187 http:// java.net /projects/ femto -java. This BoF session. Learn about a different way to develop Java code for tiny platforms e.g. smart cards
E N D
Femto JavaDeveloping Java applications for tiny footprint platforms Eduard de Jong QC Technology B.V. BOF 2187 http://java.net/projects/femto-java
This BoF session • Learn about a different way to develop Java code for tiny platforms e.g. smart cards • With unit testing of on-platform code • In multiple packages in the same project • See it used for Java Cardtmplatform code • Tiny Java platform: • A Java programmable platform with a restricted and/or modified run time • Deployment of Java code by optional pre-load processing of class files Femto Java—BOF 2187
Eduard de Jong • Invented & patented core technology used in Java Card • 1994 • Designed Java Card 2.0 • 1996 • With the Java Card team at Sun Mircosystems Inc. • Architect for DMDC deployment of smart cards (CAC) • Till 2006 • Active in ISO smart card standardization • Since 1994 • Designed electronic cash system for smart cards and mobile phones • Implemented in UK with Java for Android and the Java Card Platform • Deployments soon Femto Java—BOF 2187
The Plan for this session • Background • Femto Java basics • Femto Java Card • Conclusion Femto Java—BOF 2187
Progress • Background • Java Card vision • Java Card practices • Small Java • Femto Java basics • Femto Java Card • Conclusion Femto Java—BOF 2187
Java Card vision • Run java applications in a very restricted device • Initial constraints: • 8 bit CPU • <64K Program • <16K Non-volatile memory • <1K RAM • Specify a framework for smart card application generic operations • IO • Crypto • Memory transactions • Develop code for both sides at the same time • Communication code generated from same source • Card Applet • Card terminal application • Bypass explicit use of APDUs Femto Java—BOF 2187
JC Development practice • IDE project for Java Card platform one package at a time • All tools aimed at single-package development • Design choice in Java Card to equate Java Card’s “fire wall” with a Java package • No support for unit testing • No test driven development • Marginal support for refactoring • No compile on save Femto Java—BOF 2187
History of small Java efforts • Java Card (1996) • JC 2.0 (1997) • Femto Java I (1997) • Pico Java (1999) • Spotless (1999) • KVM • Java ME • Femto Java II (2000) • Squawk (2003) • Embedded Java (2011) • Femto Java III (2014) Femto Java—BOF 2187
Progress of this session • Background • Femto Java basics • Femto Java platform • Femto Java Code development process • Net Beans integration • Femto Java Card • Conclusion Femto Java—BOF 2187
Femto Java Femto Java: Principles & tools for developing Java code, programs and libraries, on restricted computing platforms: • Not the full Java runtime environment • Modified runtime functions • Java API with framework dedicated to platform purpose • Written in Java • Executed using a Java-like interpreter • Executable code created with post-compilation Femto Java—BOF 2187
Femto Java Development Femto Java—BOF 2187
Femto in NetBeans • NB Code development project for Java SE project • Code for restricted platform is in one or more ear-marked packages • Creates a sub project type within the NB project Femto Java—BOF 2187
Progress of this session • Background • Femto Java basics • Femto Java Card • Java Card tools • Java Card emulator • Runtime reference • Unit test support • Demo • Conclusion Femto Java—BOF 2187
Femto Java Card tools • Tools need to support multiple packages • Rethink CAP file • Java Card Converter • Wrapper around current tool • Calling order constraints enforced. • CAP tools • Load APDU scripts generated in proper package calling order • Dependency importer • Recognizes multi-package CAP files • On-card platform enhancements • AbstractApplet • Overridable initialization code • TestApplet • On-card debugging support Femto Java—BOF 2187
Femto Java Card emulator • Java Card platform API reference library • Java Card platform implementation • In Java • Implements almost all Java Card features • For (unit) testing • Platform runtime environment instantiated per test • External access to runtime static data Femto Java—BOF 2187
Unit testing The Java card runtime is instantiated at the start of each test. class ShowFemtoUnitTest { @Before void initJavaCardRuntime() { //Create the runtime for the current test (Thread) JavaCardTestContext.getInstance(); } @Test void aMethodTest(){ //e.g. call a runtime static method byte[] bArr =JCSystem.makeTransientByteArray(10, 1); //Dispatched to the current runtime instance //test code … } } Femto Java—BOF 2187
APDU Unit testing Explicit reference to Java card runtime to access APDU buffer class ShowFemtoUnitTest { JavaCardTestContext context; @Before void initJavaCardRuntime() { //Keep reference to runtime context context = JavaCardTestContext.getInstance(); } @Test void aMethodTest(){ //Set the current APDU. APDU apdu=context.makeApdu(10, 0x80, 4, 0, 0, …); //test code … assertEquals(apdu, APDU.getCurrentAPDU()); } } Femto Java—BOF 2187
APDU level testing The emulated Java Card runtime supports • Loading Java Card Applet instance • Specifying AIDfor the applet under test. • Specifying Shareable interface implementations • Initiating a session with an Applet • With answer to SELECT command • Manufacturing APDUs for Applet session Femto Java—BOF 2187
Demo Time • Opening a Java SE Project • Project prepared with Femto plugin modules • Marking packages for Java Card processing • Run unit tests for Java Card library • Existing Java Card development with deployed code Femto Java—BOF 2187
Progress of this session • Background • Femto Java basics • Femto Java Card • Conclusion Femto Java—BOF 2187
Conclusion With the “Femto” principle development of code for the Java Card platform can benefit from all the powerful present day development tools in an IDE such as unit testing and refactoring. Principle applicable to a range of constrained Java platforms Femto Java—BOF 2187
Questions? Femto Java—BOF 2187
Femto Java Eduard de Jong eduard@dejongfrz.nl http://java.net/projects/femto-java Femto Java—BOF 2187