Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK9 throws NumberFormatException #50

Open
ptahchiev opened this issue Apr 12, 2018 · 8 comments
Open

JDK9 throws NumberFormatException #50

ptahchiev opened this issue Apr 12, 2018 · 8 comments

Comments

@ptahchiev
Copy link

Hi there,

my code works fine with JDK8, however when I try to run it with JDK9 I get this exception:

Caught and handled this exception :
java.lang.NumberFormatException: For input string: ""
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Integer.parseInt(Integer.java:662)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at com.github.jaiimageio.impl.common.ImageUtil.processOnRegistration(ImageUtil.java:1401)
	at com.github.jaiimageio.impl.plugins.bmp.BMPImageWriterSpi.onRegistration(BMPImageWriterSpi.java:105)
	at java.desktop/javax.imageio.spi.SubRegistry.registerServiceProvider(ServiceRegistry.java:788)
	at java.desktop/javax.imageio.spi.ServiceRegistry.registerServiceProvider(ServiceRegistry.java:330)
	at java.desktop/javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(IIORegistry.java:212)
	at java.desktop/javax.imageio.spi.IIORegistry.<init>(IIORegistry.java:136)
	at java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:157)
	at java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)
	at com.nemesis.platform.module.barcode.core.service.impl.BarcodeServiceImpl.createBarcodeImage(BarcodeServiceImpl.java:102)

The image is rendered however, I just don't like the exception being logged.

@Jugen
Copy link

Jugen commented Apr 24, 2018

There's a new release 1.4.0 that fixes this.

@ptahchiev
Copy link
Author

Pardon my ignorance, but isn't imageio part of JDK? Does that mean that we need to communicate with the JDK team to include the latest release?

@Jugen
Copy link

Jugen commented Apr 24, 2018

It used to be part of java.net but Oracle shutdown it down about a year ago, if I'm not mistaken.
So jai-imageio became orphaned and this is now one of a few efforts to keep it available.
(BTW if you needed jai-imageio for TIF images then Java 9 supports TIF now.)

@ptahchiev
Copy link
Author

I use it for rendering PNG images:

ImageIO.write(img, "png", baos);

and apparently javax.imageio.ImageIO is class that comes from the JDK

@Jugen
Copy link

Jugen commented Apr 24, 2018

According to the stack trace you provided above, you have a barcode library by nemises that triggers javax.imageio to register plugins (looking specifically for BMP image writers, I think). So maybe this library is bundled with the nemises barcode library ?

@ptahchiev
Copy link
Author

Yep, you are absolutely right:

[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) @ samplestore ---
[INFO] com.nemesis.archetype:samplestore:war:2.0.0.BUILD-SNAPSHOT
[INFO] \- com.nemesis.platform.module:nemesis-module-barcode:jar:2.0.0.BUILD-SNAPSHOT:compile
[INFO]    \- com.google.zxing:javase:jar:3.3.2:compile
[INFO]       \- com.github.jai-imageio:jai-imageio-core:jar:1.3.1:runtime
[INFO] ------------------------------------------------------------------------

@lbellonda
Copy link
Member

If using Maven, you can exclude the 1.3.1 dependency from barcode module and add the new 1.4.0 in your pom if 1.3.1 and 1.4.0 are binary compatible as I think.
You need to test extensively your program.

Hope that helps.

@Jugen
Copy link

Jugen commented Apr 24, 2018

You can try removing this dependency in zxing/javase/pom.xml as it may not even be needed any more.

https://github.com/zxing/zxing/blob/274159117ac631ef8d48913f22ec48b0bb8d7543/javase/pom.xml#L34-L39

Note that removing the dependency probably won't produce a compile error, but your tests should fail if an image codec is needed that isn't built into Java.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants