Java Reference
In-Depth Information
* verify that a method does in fact override (not overload) a method
* from the parent class. This class provides the method.
*/
abstract
abstract class
class
Top
Top
{
public
public abstract
abstract
void
void
myMethod
(
Object o
);
}
/** Simple demonstation of Metadata being used to verify
* that a method does in fact override (not overload) a method
* from the parent class. This class is supposed to do the overriding,
* but deliberately introduces an error to show how the modern compiler
* behaves
*/
class
class
Bottom
Bottom
{
@Override
public
public
void
void
myMethod
(
String s
) {
// EXPECT COMPILE ERROR
// Do something here...
}
}
Attempting to compile this results in a compiler error that the method in question does not
override a method, even though the annotation says it does; this is a fatal compile-time error:
C:>
javac AnnotationOverrideDemo.java
AnnotationOverrideDemo.java:16: method does not override a method
from its superclass
@Override public void myMethod(String s) { // EXPECT COMPILE ERROR
^
1 error
C:>
Archiving with jar
Problem
You want to create a Java archive (JAR) file from your package (or any other collection of
files).