Bug with Override annotations in Eclipse

This is most likely because you are switching between Java 1.5 and Java 1.6. In 1.5 you couldn’t mark interface implementations with @Override, but you can in 1.6. A quick Google search turned up this good explanation of the difference in this annotation between the two versions: http://www.techienuggets.com/CommentDetail?tx=38155 Semantics of @Override is different in JDK … Read more

How can be solved java.lang.NoClassDefFoundError: javax/annotation/Generated?

Add an artifact containing the classes you need to the classpath. It appears that the javax.annotation API is what you need. See https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api/1.3.2 for details. You can add the following dependency to your project as any other and it should be present: <!– https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api –> <dependency> <groupId>javax.annotation</groupId> <artifactId>javax.annotation-api</artifactId> <version>1.3.2</version> </dependency> Remember to remove the compiler … Read more

Create Annotation instance with defaults, in Java

To create an instance you need to create a class that implements: java.lang.annotation.Annotation and the annotation you want to “simulate” For example: public class MySettings implements Annotation, Settings But you need to pay special attention to the correct implementation of equals and hashCode according to the Annotation interface. http://download.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Annotation.html If you do not want to … Read more

What’s the point of package annotations?

bnd tool (and maven-bundle-plugin) makes use of package annotations. Putting @Version and @Export annotation in package-info.java allows it to generate OSGi metadata. javadoc uses package annotations. JAXB uses package-level annotations, for example, to specify mapping of a Java type to XML Schema type package-wide. Package annotations are also used in JBoss’s xml binding. Struts 2 … Read more

Annotation attributes with type parameters

I think it is possible, but it requires lots of additions to language spec, which is not justified. First, for you enum example, you could use Class<? extends Enum<?>> options. There is another problem in Class<? extends Enum> options: since Enum.class is a Class<Enum> which is a Class<? extends Enum>, it’s legal to options=Enum.class That … Read more

Use cases for implementing annotations

I’ve never used it in practice but what you get is, that you can use classes as replacement for your annotations. Let’s create an artificial example. Say we have an documentation generator. It reads a @Docu annotation from given classes and prints the description attribute. Like this: import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; … Read more

When is @uncheckedVariance needed in Scala, and why is it used in GenericTraversableTemplate?

The problem is that GenericTraversableTemplate is used twice: once for mutable collections (where its type parameter should be invariant), and once for immutable collections (where covariance is invariably king). GenericTraversableTemplate’s typechecks assuming either covariance or invariance for the A type parameter. However, when we inherit it in a mutable trait, we have to pick invariance. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)