Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
I have a Java library I'm considering porting to C#. The Java library makes extensive use of annotations (at both build time and run time.) I've never used C# attributes, but understand that they are the rough equivalent of Java annotations. If I proceed with the port using attributes to replace annotations, what do I need to know? What's going to be the same? Different? What's going to b...
This puzzles me. I have a class with a custom annotation and I can't seem to verify that the annotation is present. What am I doing wrong here? If I run MyOperationTest (see below), I get this as a result: implements Library.Operation: true has @Library.Marker: false Tada! Library.java: package com.example.gotchas; public class Library { private Library() {} public @interface Ma...
What are the exact default values of two meta annotations (Target and Retention) in a user defined annotation? public @interface AnnotationWithDefaultProps { }
We have a JUnit test based on JDepend 2.9.1 in order to find illegal dependencies and cycles. Today we found that JDepend is missing dependencies. It doesn't seem to consider A depending on B in the following piece of code: public class A { @SomeAnotation(value = B.class) public String someMethod() { ... } } Our test looks like this: private JDepend setupJDepend() { ...
i am debugging a application using OSGi, i terribly find out that if the Annotation class is missing, the class loader would omit that annotation, if i call the method.getAnnotations(), no exception, but return nothing. i don't get it, but i do want to know if there is any way to make the JVM throw a Exception. is there any option for starting the JVM? @Target({ElementType.METHOD}) @Retentio...
 /*
  * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Sun designates this
  * particular file as subject to the "Classpath" exception as provided
  * by Sun in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 */
package java.lang.annotation;

Indicates how long annotations with the annotated type are to be retained. If no Retention annotation is present on an annotation type declaration, the retention policy defaults to RetentionPolicy.CLASS.

A Retention meta-annotation has effect only if the meta-annotated type is used directly for annotation. It has no effect if the meta-annotated type is used as a member type in another annotation type.

Author(s):
Joshua Bloch
Since:
1.5
public @interface Retention {
New to GrepCode? Check out our FAQ X