How to load changes made to native java classes?

3

Hello ,

I'm trying to run a jar file, replacing some of the original java interfaces for connecting to the database, changing the setBoolean method to receive an object as a parameter.

Original :

void setBoolean(int parameterIndex, boolean x) throws SQLException;

My change:

void setBoolean(int parameterIndex, Boolean x) throws SQLException;

My changes have been made to the PreparedStatement class so that my changes are called, when I start the application I am using the command:

java -Xbootclasspath/p:C:/Users/elizio/Desktop/safepdv700/safepdv700/src/main/java -jar safepdv.jar

Because of "-verbose: class" I can verify that it actually loads the class with my changes.

However, when setBoolean is called by the application, it does not find the method, returning me:

Exception in thread "AWT-EventQueue-0" [Loaded java.lang.Throwable$WrappedPrintStream from C:\Program Files\Java\jre1.8.0_91\lib\rt.jar]
java.lang.NoSuchMethodError: java.sql.PreparedStatement.setBoolean(IZ)V
    at com.t2tierp.pafecf.controller.ConfiguracaoController.updateCS(ConfiguracaoController.java:613)
    at com.t2tierp.pafecf.view.MovimentoAberto.validaCamposLogin(MovimentoAberto.java:448)
    at com.t2tierp.pafecf.view.MovimentoAberto.passwordTextSenhaUsuarioActionPerformed(MovimentoAberto.java:403)
    at com.t2tierp.pafecf.view.MovimentoAberto.access$200(MovimentoAberto.java:22)
    at com.t2tierp.pafecf.view.MovimentoAberto$4.actionPerformed(MovimentoAberto.java:240)
    at javax.swing.JTextField.fireActionPerformed(Unknown Source)
    at javax.swing.JTextField.postActionEvent(Unknown Source)
    at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source)
    at javax.swing.SwingUtilities.notifyAction(Unknown Source)
    at javax.swing.JComponent.processKeyBinding(Unknown Source)
    at javax.swing.JComponent.processKeyBindings(Unknown Source)
    at javax.swing.JComponent.processKeyEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.WaitDispatchSupport$2.run(Unknown Source)
    at java.awt.WaitDispatchSupport$4.run(Unknown Source)
    at java.awt.WaitDispatchSupport$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(Unknown Source)
    at java.awt.Dialog.show(Unknown Source)
    at java.awt.Component.show(Unknown Source)
    at java.awt.Component.setVisible(Unknown Source)
    at java.awt.Window.setVisible(Unknown Source)
    at java.awt.Dialog.setVisible(Unknown Source)
    at com.t2tierp.pafecf.view.Caixa.verificarMovimentoExistente(Caixa.java:3392)
    at com.t2tierp.pafecf.view.Caixa.<init>(Caixa.java:344)
    at com.t2tierp.pafecf.view.Caixa$41.run(Caixa.java:2393)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Changes made both to the Java interface and to the Mysql-Connector source code are in this repository:

link

What should I do to have my method called instead of the original since my class is being loaded according to the log?

    
asked by anonymous 05.07.2017 / 22:56

1 answer

0

It does not find the method simply because its class does not implement the method declared in the java.sql.PreparedStatement interface which is the void method setBoolean (int parameterIndex, boolean x ) see that the boolean is the primitive and not the Boolean object, so in this case you did not implement the interface method, you just created a new one. So by the time java tries to find a class with the implementation of setboolean with primitive it does not find and launches

  

java.lang.NoSuchMethodError:

    
28.09.2017 / 03:54