1

The below error compelled me to dig into the build process of a cap file in the command line without using the IDE. So now, I can build a cap file from the command line using java/javac series of commands. But I have this one applet which successfully created a cap file if built via eclipse IDE but I am encountering an error when i try to build in the command line. I am also having same error when I tried in a correctly setup gradle build settings/environment. This is the error:

[ant:convert] [ INFO: ]     Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
[ant:convert]
[ant:convert]
[ant:convert] warning: You did not supply export file for the previous minor version of the package
[ant:convert] [ INFO: ] conversion completed with 1 errors and 1 warnings.
[ant:convert] error: Class org/dx/tools/TestApplet, specified in -applet option, is abstract.

Take note, this is a working and tested applet in combination with other applets that uses this one. And this builds in the eclipse IDE.

Also I am able to generate the .class file. The problem is during the convertion of the class file to cap file.

Here is how it look like:

package org.dx.tools;

import org.globalplatform.GPSystem;
import org.globalplatform.SecureChannel;

import javacardx.apdu.ExtendedLength;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.Util;
import javacard.framework.APDU;
import javacard.framework.APDUException;
import javacard.framework.Applet;
import javacard.framework.AppletEvent;    

public abstract class TestApplet extends Applet implements AppletEvent, 
    ExtendedLength {
  ...
}

This .cap is one among five others. The others are not abstract, but inherits from this one. Since it build in eclipse IDE, I can actually build the other cap files by taking the output of the IDE had produce. First, I jar the classes since as I said I can create the classes and feed to java conversion command to build the other caps, and I also use the TestApplet.exp that the IDE generated.

UPDATES: 2019/11/17 Here is the actual java command options that is able to build from .class to .cap. I took this as exactly from the Eclipse IDE conversion log.

If an answer can confirm this is a current gradle limitation then I will accept this answer. If answer can show what is the correct gradle settings to make it work then I will accept this answer. Thanks.

daparic
  • 3,794
  • 2
  • 36
  • 38
  • I followed the exact `java` conversion invocation parameters emitted by Windows eclipse IDE when converting the `.class` to `.cap` and type this very same exact command in a linux machine and it was able to convert the `.class` to `.cap`. Staying away for a while from gradle magic for the mean time until somebody here can comment on whats happening here. – daparic Nov 14 '19 at 05:24

2 Answers2

0

This is very likely due to linking to a newer or older version of a library, while targeting a different Java Card version during your build process. Note that the converter creates pre-linked code, so it expects to link against the correct versions.

This is different from Java SE, where the classes can be linked at runtime and the location of methods and fields doesn't matter, as they are created during runtime.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
  • Thanks for the info. I am keeping this question open, and the answer that I will accept is an answer that shows the proper gradle settings that can convert the `TestApplet` class above to a `.cap` (or an `.exp` would be enough). I will also accept an answer that can confirm that this is a current limitation in gradle. I just added the actual `java` command that was able to convert the `.class` to `.cap` for reference. – daparic Nov 17 '19 at 10:54
  • That's fair I suppose. Java Card is a small community, you might (have to) consider fixing it yourself... – Maarten Bodewes Nov 17 '19 at 15:37
0

I've resolved the issue by removing the applet {} block in build.gradle. As the particular cap being built is an abstract class, it does not have an applet aid.

daparic
  • 3,794
  • 2
  • 36
  • 38