Apparently I can't use classes generated with APT in unit tests that use static imports. (Maven sample project can be downloaded here )
If the following sample class
import com.mysema.query.jpa.impl.JPAQuery;
public class UserStore {
public void something() {
new JPAQuery(null).from(QUser.user).list(QUser.user.login);
}
}
is changed to
import static something.QUser.user;
import com.mysema.query.jpa.impl.JPAQuery;
public class UserStore {
public void something() {
new JPAQuery(null).from(user).list(user.login);
}
}
the build process (mvn clean install) will fail:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.466s
[INFO] Finished at: Wed May 30 16:05:40 CEST 2012
[INFO] Final Memory: 18M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project apt-bug: Compilation failure: Compilation failure:
...
Does this mean that I cannot use these generated classes with static import in unit tests or is there a problem in the pom.xml files?
EDIT:
POM file: http://pastebin.com/gvycZmXD
This might be related https://github.com/mysema/querydsl/issues/158
I have not yet had the time to investigate this.
Edit
This has apparently been fixed now in Java 7
I assume the problem is located in the static import, cause the error messages says the imported QUser.user is neither a class nor an interface. This looks like the user is just an attribute of the Class QUser which would explain the error message.
/home/xxx/apt-bug/src/main/java/something/UserStore.java:3: cannot find symbol
symbol : class QUser
location: package something
import static something.QUser.user;
^
/home/xxx/apt-bug/src/main/java/something/UserStore.java:3: static import only from classes and interfaces
import static something.QUser.user;
^
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.