I need to extend class A
but it needs to override its constructor.
package com.example.io; // Package belongs to jar from maven dependency
public class A {
A(String s, Integer i) {
// constructor code
}
// other methods
}
As it is default constructor (a constructor with only package access) I cannot access outside the package, so I created same package name in my source code com.example.io
and extended class A
and built successfully.
package com.example.io; // Package belongs to my source code
public class B extends A{
B(String s, Integer i) {
super(s, i); // Throws error on runtime
}
// other methods
}
But it throws runtime error saying -
java.lang.IllegalAccessError: tried to access method com.example.io.A.<init>(Ljava/lang/String;Ljava/lang/Integer;)V from class com.example.io.B
How do I solve this? I mean, is there any way I can extend class A with default constructor?
B