0

I'm moving database from 11G to 12C. Application is currently running on java5 and uses ojdbc14.jar When I move to ojdbc6.jar, I get

java.lang.IllegalAccessError: tried to access class oracle.jdbc.driver.OracleResultSet

Upon opening up both jar files and comparing, I see that access modifier on OracleResultSet is no longer available in ojdbc6.jar

Question: Is there a way to override the import in the class at run time via java parameter instead of changing in the class and recompiling the code. The problem is, I no longer have source code hence looking for a way to overwrite the import made in a specific class.

I understand where or what is causing the error, need to know if there is a way to overwrite the import at run time.


import oracle.jdbc.driver.OracleResultSet;
import java.sql.ResultSet;
import java.sql.Clob;
import java.sql.PreparedStatement;
.
.other imports

I can change the import to oracle.jdbc.OracleResultSet and it will work.But I will have to make a direct change in .class file as source code is no longer available.

  • There is no `import` in the class file (see https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html ). So, as per https://stackoverflow.com/questions/9680295/import-statement-byte-code-significance Import statements are just compile-time shorthand for human use. – racraman Sep 30 '19 at 04:29
  • No, you can't! One way is to decompile the class and modify it, the other way is to develop a new application if source code is missing. – LHCHIN Sep 30 '19 at 05:00
  • You could use [ASM](https://asm.ow2.io/javadoc/org/objectweb/asm/commons/ClassRemapper.html) to change the class file. – Johannes Kuhn Sep 30 '19 at 05:49
  • Why? Are you using some feature that isn't in `java.sql.ResultSet`? If not, that's what you should be importing. And if you're charged with maintaining an application with no source code you implicitly have licence to write replacement source code. – user207421 Sep 30 '19 at 06:27

1 Answers1

0

No, that's not possible and probably there should be more code changed. There will be some code what uses the OracleResultSet what should be changed.

For now decompiling might work, but maybe this code should be replaced by a new implementation. It's probably easier to apply changes / bugfixes in the future

R.Groote
  • 88
  • 7