Skip to main content

[jsr353-experts] Re: JsonParser.close() and exceptions

  • From: Werner Keil < >
  • To:
  • Subject: [jsr353-experts] Re: JsonParser.close() and exceptions
  • Date: Mon, 17 Dec 2012 17:09:35 +0100

I don't understand what it has to to with JDK 8.
AutoCloseable exists since Java 7, and the main scope for this JSR is being a part of Java EE 7 (which by definition builds on Java SE 7) 

JSR 360, the only sub SE platform which may use this JSR (all others like J2ME are out of scope, they didn't even have generics, etc.) states
Try-with-resources
as one of the features, so even on CLDC 8 this would not have to be changed.

If you haven't asked Mark Reinhold and the platform team (probably even Linda and Bill in that case, too) what he said about using BigDecimal for the number type should apply in similar ways here. If we don't use AutoCloseable, then the only alternative could be http://docs.oracle.com/javase/7/docs/api/java/io/Closeable.html
(which extends AutoCloseable, but existed ever since Java 5)

Not using try-with-resource (http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html) seems irresponsible for a Java EE 7 generation JSR. If we were able to use the Java 5+ Closeable (I believe there are other references to java.io already) it may be more flexible, even towards EE6, should that be an acceptance criteria for some containers or vendors.

Werner

On Mon, Dec 17, 2012 at 4:55 PM, wenshao < " target="_blank"> > wrote:
if jsr353 is a part of JDK 8, should AutoCloseable. if it is library, should not be AutoCloseable.

-+ wenshao +-


Date: Sat, 15 Dec 2012 10:21:20 -0800
From: " target="_blank">
To: " target="_blank">
Subject: [jsr353-experts] Re: JsonParser.close() and exceptions


On 12/15/12 9:45 AM, Werner Keil wrote:
Why would we target Java 6 with this release?
Java 7 is final, and I heard, 6 is phased out by March 2013 or so.
It would make great sense, to allow "try with resource" unless some users or developers insist on using Java 6 forever?
They can still take advantage of ARM blocks and use SE 7 features in the applications(It is just that we use Closeable instead of AutoCloseable in the API but that doesn't restrict them to use only wiht SE 6)

My preference is to use SE 7 as the base. We had the following discussion[1] and some of them suggested the need to use SE 6, so we went with it. If that's not case, let me know. We can gladly use SE 7 as the base and AutoCloseable !

Jitu

[1] http://java.net/projects/json-processing-spec/lists/users/archive/2012-10/message/2

While leaving subsetting an option for later (AFAIK CLDC 8 also plans to support "try with resource" the main scope for this JSR is Java EE7 which is based on Java7 anyway.
Werner
Am 15.12.2012 18:39 schrieb "Jonathan Fuerth" < " target="_blank"> >:
JsonParser.close() documents that it closes the underlying input source if there is one. The underlying input source is wrapped in JsonTokenizer and JsonTokenizerReader, both of which declare IOException on their close() methods and let any exceptions pass through. But JsonParserImpl.close() chooses to wrap the IOException in an (unchecked) JsonException. This is not mentioned in the doc comment.

At first I was going to file a JIRA with a suggested rewording of the doc comment on JsonParser.close(), but I think this warrants discussion.

I guess the value of using the unchecked JsonException on JsonParser.close() is that it eliminates the need for exception handling when client code knows it is using the JsonStructureParser implementation, which never throws IOExceptions. On the other hand, leaving JsonParser.close() without a checked IOException tempts lazy developers (like me!) to leave off the try/catch around the call to close(), even when we know there might be a real InputStream underneath.

On the other other hand, none of this matters much when JsonParser is used together with try-with-resources in Java 7. In this case, close() will always be called with proper exception handling. But I guess we're still targeting JDK6 with this API.

I think my preference is still for IOException in JsonParser.close(). What does everyone else think?

-Jonathan




[jsr353-experts] Re: JsonParser.close() and exceptions

(continued)

[jsr353-experts] Re: JsonParser.close() and exceptions

Jitendra Kotamraju 12/15/2012

[jsr353-experts] Re: JsonParser.close() and exceptions

Werner Keil 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: JsonParser.close() and exceptions

Jonathan Fuerth 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: JsonParser.close() and exceptions

Werner Keil 12/17/2012

[jsr353-experts] Re: JsonParser.close() and exceptions

wenshao 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: JsonParser.close() and exceptions

Jonathan Fuerth 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: JsonParser.close() and exceptions

Werner Keil 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: Re: JsonParser.close() and exceptions

Jonathan Fuerth 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: Re: JsonParser.close() and exceptions

Werner Keil 12/17/2012

[jsr353-experts] Re: [json-processing-spec users] Re: Re: Re: JsonParser.close() and exceptions

wenshao 12/18/2012

[jsr353-experts] Re: JsonParser.close() and exceptions

Werner Keil 12/17/2012
 
 
Close
loading
Please Confirm
Close