Interface implementation getting lost - java

I have a class like that:
public class ClassA implements InterfaceA {}
but when I compile this using Maven and decompile the file ClassA.class using JAD i got only this.
public class ClassA {}
In another project package this don't happenig...
Someone knows why this is happening?

Related

How to generate Query classes when an entity extends a class from an external package that does not have support for QueryDsl?

I am having an entity class like below:
public class Apple extends ExternalClass implements Serializable {}
Here Apple is extending a class ExternalClass which is a part of a external package(not part of project source code).
When I am trying to use mvn compile, the compilation is failing with an error
error: cannot find symbol
symbol: class QExternalClass
location: package com.example.models
public final com.example.models.ExternalClass _super = new com.example.models.ExternalClass(this);
One solution that I can think of is to add QueryDsl to the external package, and then importing it. Is there any other solution available for this problem.

How to access a public class method in a Jar file

This might be a dumb question, but somehow i am unable to crack it.
I have create a maven project(Project 1) and defined a public method. I have created the jar(foo.jar) file using mvn verify.
package com.aaa.bbb;
public class FooClass{
public void fooMethod(){
System.out.print("Hello World");
}
}
In another project(Project 2) i added this jar in Eclipse configure build path -> libraries.
I cleaned this project and updated it.
When i wanted to access FooClass and its method it is saying FooClass cannot be resolved as type.
package com.iii.jjj;
import com.aaa.bbb; //Throwing an error saying the import com.aaa.bbb cannot be resolved
public class TestClass{
public void printMsg(){
FooClass obj=new FooClass(); //throwing error here FooClass cannot resolved to a type
}
}
But when i create another class extends FooClass, it is properly identifying.
package com.iii.jjj;
public class TestClass2 extends FooClass{ //It is working fine here
}
Tried different solutions, but no luck yet. Can someone help?

JavaEE: Custom class in a EJB remote interface

I want to add my class as an argument in the stateless, remote interface. For example:
In my remote interface I have this method
void connect(MyClass myClass);
But I didn't import MyClass (which is a Java Class library) in my interface, so I got an error. Is there any workaround?
In my SessionRemote class I imported MyClass library. Is there any chance to override that method in SessionRemote without importing MyClass in the interface?
#Override
public void connect(MyClass myClass){
myClass.foo();
}
I tried to add MyClass library to the interface, but I got lots of errors.

JAVA - Problems with Override on Interface and Class

Salve...
some Problem for me in Java. I have generated an Interface and an Class implements this Interface. In the Interface i have declared one Method... and in the Class i will Override this. But not works! But don`t why....
See my example Interface:
public interface IMyClass extends IInterfaceA<IInterfaceB> {
public List<IInterfaceB> getMethod(Integer id);
}
See now my Class File:
public class MyClass implements IMyClass {
#Override
public List<IInterfaceB> getMethod(Integer id) {
return anything;
}
}
Problem is... i think i make no mistake. And next - i surprise that i have another Interfaces and Classes with the same Logic - and it will work and make no Problems!
In my another Interfaces & Classes i don`t need to make the Class with implements the Interface an Abstract Class.
When i make an build... Jenkins will surprise me with this Message:
[ERROR] COMPILATION ERROR :
error: MyClass is not abstract and does not override abstract method getMethode() in IMyClass [ERROR]
error: method does not override or implement a method from a supertype [INFO] 2 errors [INFO]
Solved . The " solution " - was a build problem . After tens of Maven Clean Installs and re- builds he has the connection interface and class savvy and it goes... oh men ;)

Java compiler api error

I'm trying to compile in-memory a class that implements an interface.
I have an interface named CacheRule (in com/vpfw/proxy/logicRules/CacheRule.class).
I have a class named CacheRuleBean that I compile in-memory.
If this class does not implement CacheRule, compilations works. But if this class implements CacheRule, then the error is:
java.lang.NoClassDefFoundError: com/vpfw/proxy/logicRules/CacheRule (wrong name: com/vpfw/proxy/logicRules/CacheRuleBean)
Curiously, if I perform this compilation inside Eclipse, works.
But when I execute it from Tomcat, I get the previous error.
This is the code for the CacheRule interface:
package com.vpfw.proxy.logicRules;
public interface CacheRule
{
void executeRule();
}
This is the code for CacheRuleBean:
package com.vpfw.proxy.logicRules;
import com.vpfw.proxy.logicRules.CacheRule;
public class CacheRuleBean implements CacheRule
{
public void executeRule() {}
}
And the call to compile is:
String[] compilationOptions = { "-cp", classDir };
return (new CompilerService().compile("com.vpfw.proxy.logicRules.CacheRuleBean",
source, compilationOptions));
Where
classDir is the directory /home/app/WEB-INF/classes that contains the com folder of this project (classPath is correct, If I add another classes of this project as imports in CacheRuleBean, compile ok).
The name of the class I use is com.vpfw.proxy.logicRules.CacheRuleBean.
source is the source code of CacheRuleBean.
CompilerService is my implementation of compiler API, which works perfectly with all classes except those that implement an interface.
What can I be doing wrong?

Categories

Resources