Compiling Source Files with JAV Extension Myth in Java Language Spec 3.0

I' ve read something interesting about java source file extensions at Top level type declarations section in java langugae specification 3.0.

When packages are stored in a file system (§7.2.1), the host system may choose to enforce the restriction that it is a compile-time error if a type is not found in a file under a name composed of the type name plus an extension (such as .java or .jav) if either of the following is true: • The type is referred to by code in other compilation units of the package in which the type is declared. • The type is declared public (and therefore is potentially accessible from code in other packages).

While in this paragraph is mentioning about top level type class declarations and source file naming conventions; it is pointing that the java source files could be with file extensions .jav. Immediately, i tried with a sample demo class with name Demo.jav.

public class Demo { 
 public String toString() {
  return super.toString() + "\tI am Demo class with jav extension";

The output is not a surprise and disappointed me :) the source file name is detected as a javac command line flag...

H:\jav source>javac -verbose Demo.jav
javac: invalid flag: Demo.jav
Usage: javac  
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath           Specify where to find user class files
  -cp                  Specify where to find user class files
  -sourcepath          Specify where to find input source files
  -bootclasspath       Override location of bootstrap class files
  -extdirs             Override location of installed extensions
  -endorseddirs        Override location of endorsed standards path
  -d              Specify where to place generated class files
  -encoding        Specify character encoding used by source files
  -source           Provide source compatibility with specified release
  -target           Generate class files for specific VM version
  -version                   Version information
  -help                      Print a synopsis of standard options
  -X                         Print a synopsis of nonstandard options
  -J                   Pass  directly to the runtime system

Popular posts from this blog

SoapUI 4.5.0 Project XML File Encoding Problem

COMRESET failed (errno=-32)

SoapUI - Dynamic Properties - Getting Current Time in DateTime Format