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

bitronix.tm.osgi.Activator class is incompatible with JDK5 #17

Closed
rankinc opened this issue Apr 1, 2014 · 10 comments
Closed

bitronix.tm.osgi.Activator class is incompatible with JDK5 #17

rankinc opened this issue Apr 1, 2014 · 10 comments

Comments

@rankinc
Copy link
Contributor

rankinc commented Apr 1, 2014

The Activator class contains these lines:

FileReader fileReader = new FileReader(cfgFile);
try {
    btmProperties.load(fileReader);
}
finally {
    fileReader.close();
}

Unfortunately, the Properties.load(Reader) API only exists since JDK6. To be compatible with JDK5 (which is your declared target), you need to use a FileInputStream instead of a FileReader.

Or you could switch to JDK6, now that JDK8 has been released.

On the positive side, this does appear to be the only JDK6 issue in the project.

@vladmihalcea
Copy link

Hi,

I am not sure how many are still running on JDK 5 which reached it "end of life" already: http://www.oracle.com/technetwork/java/javase/1-5-137169.html.
Maybe the minimum supported JVM should be updated to 1.6

Vlad

On Tuesday, April 1, 2014 11:40 AM, rankinc notifications@github.com wrote:

The Activator class contains these lines:
FileReader fileReader = new FileReader(cfgFile);
try { btmProperties.load(fileReader);
}
finally { fileReader.close();
}
Unfortunately, the Properties.load(Reader) API only exists since JDK6. To be compatible with JDK5 (which is your declared target), you need to use a FileInputStream instead of a FileReader.
On the positive side, this does appear to be the only JDK6 issue in the project.
Or you could switch to JDK6, now that JDK8 has been released.

Reply to this email directly or view it on GitHub.

@lorban
Copy link
Contributor

lorban commented Apr 1, 2014

BTM 2.1.x' target was JDK 1.5 but I think we can reasonably make 3.0.0 require JDK 1.6.

@rankinc
Copy link
Contributor Author

rankinc commented Apr 1, 2014

I wouldn't object to that ;-). That would mean that we could also replace constructs such as:

 throw (SQLException) new SQLException("unilateral rollback of " + this).initCause(ex);

with:

throw SQLException("unilateral rollback of " + this, ex);

And that we wouldn't need to use Reflection in order to invoke Connection.isValid().

Not to mention proper use of @OverRide...

@brettwooldridge
Copy link
Contributor

You still need reflection because even though Java 6 defines the isValid()
signature, many drivers are only JDBC2/3 compliant (pre-Java 6) and do not
implement the method. So at runtime an exception is thrown when isValid()
is invoked. I forget which, maybe AbstractMethodException or something.
Anyway, we can't get rid of the reflection for probably a long time to
come.

On Tue, Apr 1, 2014 at 2:10 AM, rankinc notifications@github.com wrote:

I wouldn't object to that ;-). That would mean that we could also replace
constructs such as:

throw (SQLException) new SQLException("unilateral rollback of " + this).initCause(ex);

with:

throw SQLException("unilateral rollback of " + this, ex);

And that we wouldn't need to use Reflection in order to invoke
Connection.isValid().

Reply to this email directly or view it on GitHubhttps://github.com//issues/17#issuecomment-39184788
.

@rankinc
Copy link
Contributor Author

rankinc commented Apr 2, 2014

OK, but the SQLExceptions and @OverRide annotations are fair game... ;-).

@lorban
Copy link
Contributor

lorban commented Apr 2, 2014

Yes, they are. FYI BTM was designed during the JDK 1.4 era, so quite a fair bit of its architectural design was done with those limitations in mind. Support for JDK 1.5+ constructs were added later on here and there but I don't think we ever did a complete code review to use all the new constructs. If you feel like reviewing them, feel free!

@rankinc
Copy link
Contributor Author

rankinc commented Apr 2, 2014

Indeed, I think I saw a "migrate to JDK5 so that we can use Generics" commit somewhere... ;-)

@rankinc
Copy link
Contributor Author

rankinc commented Apr 2, 2014

BTW, how did you obtain jdbc-3.0.jar please? That will obviously need updating to jdbc-4.0.jar for Java 6.

@rankinc
Copy link
Contributor Author

rankinc commented Apr 4, 2014

It turns out that I don't need a complete jdbc-4.0.jar. All I really need (so far, anyway) is to recreate JDBC 4.0's CommonDataSource, Connection and Driver interfaces, because these are the main API differences between 4.0 and 4.1. Once overlaid on top of JDK7, then JDK7's native JDBC API turns back into 4.0.

This approach is far more likely to comply with BTM's Apache licence than downloading the complete 4.0 API from the Internet ;-).

@rankinc
Copy link
Contributor Author

rankinc commented May 26, 2014

BTM now requires JDK6.

@rankinc rankinc closed this as completed May 26, 2014
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

4 participants