Isn't it inconsistent in JLS (Java Language Specification)?

In section 11.2 Compile-Time Checking of Exceptions, Chapter 11 Exception , JLS,
it says "Static initializers (�8.7), class variable initializers, and instance initializers or instance variable initializers within named classes and interfaces (�8.3.2), must not result in a checked exception; if one does, a compile-time error occurs."
but in 8.6 Instance initializers, it says "An instance initializer of a named class may not throw a checked exception unless that exception or one of its superclasses is explicitly declared in the throws clause of each constructor of its class and the class has at least one explicitly declared constructor. "
Isn't is inconsistent?

From the Java Spec Report
http://www.ergnosis.com/java-spec-report/java-language/jls-11.2.html
jikes 1.14 implements this. The Sun jdk 1.3.1 compiler does not.

Similar Messages

  • Java Language Specification error reports

    Well, I wanted to report a typo in The Java Language Specification, Third Edition (http://java.sun.com/docs/books/jls/download/langspec-3.0.pdf), so from http://java.sun.com/docs/books/jls/ I clicked on the "feedback form" link (which points at http://developers.sun.com/contact/feedback.jsp?&category=doc&mailsubject=Java%20Language%20Specification%20Feedback). This was redirected to http://www.oracle.com/technetwork/community/join/overview/index.html which offers no such feedback form. Consider this sort-of-broken link as the first problem I'm reporting.
    The second problem is in the aforementioned pdf, section 4.8 (Raw Types), page 58, where on can read:
    "The type of the member(s) of Inner depends on the type parameter of Outer. If Outer is raw, Inner must be treated as raw as well, as their is no valid binding for T."
    This should be instead:
    "The type of the member(s) of Inner depends on the type parameter of Outer. If Outer is raw, Inner must be treated as raw as well, as there is no valid binding for T."
    I think a forum category should be created for just this: error reports about the documentation (pdfs, APIs, support web pages).
    Edited by: Urhixidur on 2011-09-08 09:23

    Your intentions are admirable, but you are probably wasting your time. This is a forum for Java development related questions and 99.5% of the visitors are not related to Oracle at all. most likely nothing will be done with your information.
    I think a forum category should be created for just this: error reports about the documentation (pdfs, APIs, support web pages).It is a good idea actually, but such a thing would need very tight moderation and then there is still the question of how to arrange that something is actually done with the reports.

  • Java language specification

    1. Need most full on-line java language specification.
    2. How to convert String to int?

    You can convert only string wrapped numbers in to
    int, not all strings.wrong. It all depends on the algorithm you use and
    what meaning you wish to assign to the outcome...
    Take a hashcode for example, you can create one from
    a string and it is an integer value.I think he meant one can only parse strings containing "0-9" to int's.
    That is not true of course, because you can parse strings with base > 10.

  • How to start learning java language?

    can any one advise me how to start with

    can any one advise me how to start withJVerd's post is great.
    Also there are some links I have compiled over the last few months along with others in this forum.
    Free Tutorials and Such
    Installation Notes - JDK 5.0 Microsoft Windows (32-bit)
    Your First Cup of Java
    The Java? Tutorial - A practical guide for programmers
    New to Java Center
    Java Programming Notes - Fred Swartz
    How To Think Like A Computer Scientist
    Introduction to Computer science using Java
    The Java Developers Almanac 1.4
    Object-Oriented Programming Concepts
    Object-oriented language basics
    Don't Fear the OOP
    Free Java Books
    Thinking in Java, by Bruce Eckel (Free online)
    Core Servlet Programming, by Merty Hall (Free Online)
    More Servlets, by Marty Hall (Free Online)
    A Java GUI Programmer's Primer
    Data Structures and Algorithms
    with Object-Oriented Design Patterns in Java, by Bruno R. Preiss
    Introduction to Programming Using Java, by David J. Eck
    Advanced Programming for the Java 2 Platform
    The Java Language Specification
    Books:
    Head First Java, by Bert Bates and Kathy Sierra
    Core Java, by Cay Horstmann and Gary Cornell
    Effective Java, by Joshua Bloch
    Also if you are in school, definatly take a intro to programming course.
    Have Fun,
    JJ

  • Java language proposal #1

    The overhead of reference counting has led to a preference for mark-and-sweep garbage collection. But this has some obvious disadvantages as well. For example, creation of temporary objects chews up memory; this reduces performance due to having to search for unused objects during garbage collection. Although incremental garbage collection can spread the search cost evenly over time, this does not reduce the cost.
    It is evident that both reference counting and mark-and-sweep have their place. Although it is conceivable that the JVM could dynamically choose between the two for any given class, this seems difficult to implement.
    The Java language specification should allow the programmer to specify whether a class is reference counted or not. To maintain compatibility, reference counting could be specified by adding the "transient" keyword to the class declaration.

    It wasn't only the "overhead" of reference counting that led to the use of other methods of garbage collection. There was also the problem that circular references (which are very common) meant that islands of inter-reference could never be collected, leading to memory leaks. This is the case in Visual Basic, for example, and it's sometimes surprisingly difficult to write code to get circular references unlinked so that garbage collection can take place.
    There's also the problem that the existing method of garbage collection (which can be summarized as "Don't refer to it and it will go away") appears to be too complicated for many programmers to understand, leading them to voodoo coding styles to "get around it". So I don't support making it even more complicated.

  • How to convert a sql query to a java language?

    A sql like this:"update myoracletable set name='myname',age=26,sex='female',address=NULL,visittime=SYSDATE,visitnum=visitnum+1where name='name' and address='address'",I want to use java language update such as :rs.updateString(),rs.updateDate() but not a sql update.How can I do in this case?

    Something like this?
    try{
         DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
         Connection con = DriverManager.getConnection("jdbc:oracle:thin:@your_server:1521:sid","scott","tiger");
         Statement st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
         ResultSet rs = st.executeQuery("SELECT deptno,dname,loc FROM dept where deptno=28");
         while(rs.next() ) {
              rs.updateString(2,"Some Name");
              rs.updateString(3,"Some Location");
              rs.updateRow();
              System.out.println(rs.getString(1)+" : "+rs.getString(2)+" : "+rs.getString(3));
    } catch (Exception e) {
         System.out.println(e);
    }Sudha

  • I know c,c++ and java language ! and i want to contribute for development of mozilla products ! any idea where i can find beginner level projects ?

    I know c,c++ and java language ! and i want to contribute for development of mozilla products ! any idea where i can find beginner level projects ! so that i can hone some real development skills too :)

    You could also try jumping in on some of the Mozilla IRC chat channels as was suggested to someone else in another thread.
    Also you could also try the [/forums/buddies new contributors forum], it does now have an Admin monitoring and replying. (At the time of the quoted post Admins were almost impossible to get hold of for forum matters )
    ''Noah_SUMO [/forums/buddies/710569#post-61671 said]''
    <blockquote>
    Sorry I didn't see this earlier. :)
    I know just the places where I think you'd fit in best. To make sure, just join us in #sumodev and #mozwebqa and #communityit at irc://irc.mozilla.org
    I think your skills in php, javascript, python and server admin-y stuff will come in real handy at these places. :D
    For example, some help is needed here to fix these tests after a new theme was added to wiki.mozilla.org and they are in python. https://github.com/mozilla/wiki-tests - more info in #mozwebqa
    And maybe some help with perl might be needed with firebot, a irc bot written in perl. Channel #firebot for that.
    And #communityit (for server admin stuff) and #sumodev could use some help as well, just pop in and ask. :)
    </blockquote>
    Also see
    * [[Contributor News & Resources#w_communication-channels]]_communication-channels
    ** Mibbit link (this one for #sumo channel ) https://www.mibbit.com/?server=irc.mozilla.org&channel=%23sumo
    P.S. and see
    * https://wiki.mozilla.org/Good_first_bug

  • Logic for user defined function in java language.

    Hi Guys,
    I want to use a "&" function in below code & include vafrdate.substring(130,132).equals("01").
    if ( delperiod.substring(4,6).equals("01") )
    Need your help to include & function in java code.
    In layman language , i need,
    if ( delperiod.substring(4,6).equals("01")  & (vafrdate.substring(130,132).equals("01"))
    pls help me to do it in java language.

    Santosh,
    Use this -
    if ( delperiod.substring(4,6).equals("01")  && vafrdate.substring(130,132).equals("01"))
    Regards,
    Neetesh

  • Some changes we need in the Java language

    Dear Java language makers,
    I'm actually coding a fairly complex program, and I'm facing several issues c++ does solve while Java doesn't handle them. I strongly wish these features could be included in next editions of the Java language, and I think I'm not the only one...
    1) Friend Class access
    Say I have a parser and a Data structure. The parser reads a file, and updates another class (being a data structure) as it parses line by line an input text file.
    I want my parser to fill up the data structure step by step, that is field after field, rather than using a constructor, because the information appears sequentialy in my text input file.
    Using a constructor to intitialize my data structure (rather than field by field access on a void object)would require me creating several variables in my parser for buffering the information, then create my object. This results in a loss of coding performance, and execution performance (spending time allocating and killing buffer values).
    On the other hand, I don't want these field values to be exposed to the users of my SDK, I want them to be accessed thru accessor methods.
    You would answer me : put both classes in the same package, and declare the fields of the data structure "protected", and accessors "public".
    Yes, that is a solution...but if you do really think Object Oriented, this sucks. Because a data structure and a parser are not the same thing, and I want to have them in separate packages.
    one being named myApp.Datasets, the other being named myApp.Parsers.
    And this can't be done with Java.
    If only I could declare in my data structure class the Parser class as a Friend Class, this would solve the issue and be CLEAN for Object Oriented programming !
    2) Operators
    This very annoying the Java language doesn't support operators
    Say you have a Vector3D class and you want to make a calculation :
    in c++, you can define operators for your class, and make a calculation like this :
    float a;
    Vector3D v1,v2,v3;
    //calculation
    v1 = v2 - v3 * a; //clean and easy to read
    Now in Java, not having operators, you have to deal with functions :
    float a;
    Vector3D v1,v2,v3, tmpv;
    v1=new Vector3D();
    tmpv=new Vector3D();
    //calculation
    tmpv.sub(v2,v3);
    tmpv.mul(a);
    v1=tmpv; //dirty and unreadable
    In Java you get 3 lines for a basic calculation. This is the way it's implemented in JAVA3D, and this is the best you can do in Java to my opinion.
    Just imagine how math code looks in java when you code a 3D Physics engine, regarding the previous exemple, and having to deal with matrices, vectors, quaternions...Well I give you a taste, a simple slice of the code :
    vtmp.cross(Airplane.vAngularVelocity,Element.vCGCoords); // rotational part
    vLocalVelocity = add(Airplane.vVelocityBody , vtmp);
    fLocalSpeed = magnitude(vLocalVelocity);
    if(fLocalSpeed > 1) vDragVector = div(negate(vLocalVelocity),fLocalSpeed);
    Vector3f v = new Vector3f();
    v.cross(vDragVector,Element[i].vNormal);
    vLiftVector.cross(v,vDragVector);
    tmp = magnitude(vLiftVector);
    vLiftVector=normalize(vLiftVector);
    v=new Vector3f(vDragVector);
    tmp = v.dot(Element[i].vNormal);
    Got it ? :)

    Because a data structure and a parser are not the same thing,
    and I want to have them in separate packages.Because a data structure and a parser are not the same thing, you should not jave them as the same type (class or interface), that is right. But this does not prevent us from putting them into the same package!
    java. lang.Integer and java.lang.String are not the same thing, but I am quite happy with them as classes in the same package.
    Put both classes in the same package, and declare the fields
    of the data structure "protected", and accessors "public".Protected access would allow access for inheriting classes as well. The default (package-wide) access would be better.

  • Can you write javac in java Language

    Hi,
    is it possible to write java compiler in java language.

    Here's a compiler written in Java, it is part of an IDE I wrote:
    Compiler.java: import java.io.*;
    * Wrap up javac.
    * The class exists to supply a single method - to compile a file
    * and report status along with error/success messages
    * Compilation (by javac) is carried out asynchronously using a
    * background Thread. Status and any error messages are passed back to
    * the calling object through a callback method.
    public class Compiler implements Runnable
        * Constructor.
        * @param owner the <TT>JavacTool</TT> that has created this Compiler
       public Compiler( CompilerListener owner )
          myOwner = owner;
       private CompilerListener myOwner;
        * Compile a file using javac.
        * This method will compile a Java source file and report both the
        * status of the operation and any error strings produced.
        * The method kicks off a separate Thread that actually carries out
        * the compilation. Upon completion a the JavacTool is called back with
        * a CompilerStatus object.
        * @param filename   the name of a file which <I>must</I> be in the same directory
        * as the JavacTool was run from.  this tool does not have tha capability
        * of working across multiple directories.
       public void compile( String fileToCompile )
          filename = fileToCompile;
          new Thread( this ).start();
       private String filename;
        * The method run by the separate Thread.
        * It runs once for each filename passed to the Compiler object.
        * It creates a new OS process to run "javac filename" externally
        * and captures the error output from the real compiler into
        * a String so that it can be returned to the calling code via
        * a callback method (very similar in principle to an event)
       public void run()
          CompilerStatus returnValue = new CompilerStatus();
          returnValue.outputString = new String();
          try
             Runtime r = Runtime.getRuntime();
             Process p = r.exec( "javac " + filename );
             InputStream is = p.getErrorStream();
             BufferedReader rdr = new BufferedReader( new InputStreamReader( is ) );
             String line = rdr.readLine();
             while( line != null )
               returnValue.outputString += (line + "\n");
               line = rdr.readLine();
             p.waitFor();
             returnValue.exitValue = p.exitValue();
             if( returnValue.exitValue == 0 )
               returnValue.outputString = "Compilation successful\n\nNo errors\n";
          catch( Exception e )
            e.printStackTrace();
          myOwner.compileComplete( returnValue );
    } CompilerStatus.java: public class CompilerStatus
       public int exitValue;
       public String outputString;
    }JavacTool.java: import java.util.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * The main class in the application
    * Provides the screen presence for the controllers and the output view
    public class JavacTool extends JTextArea implements CompilerListener
        * Constructor for the tool
        * @param list A java.util.Vector containing the list of files for compilation
        * or null if none entered.
       public JavacTool( JTextArea jTextArea )
          // View    
          outputWindow = jTextArea;     
          outputWindow.setFont( new Font( "Monospaced", Font.PLAIN, 12 ) ); 
          outputWindow.setText( "TBJava IDE: -ready to compile" );   
          // Get it going!
          // Must create a Compiler object and provide it with a link
          // so that it can call this object back when it has completed
          theCompiler = new Compiler( this );
          // set the size and the visibility
          setSize( 500, 250 );
          setVisible( true );
         public void Compile( String fileToCompile )
                // Infrom user that something is happening
                   filename = fileToCompile;
                   outputWindow.setBackground( Color.white );
                   outputWindow.setText( "Compiling " + filename );
                   setCursor( new Cursor( Cursor.WAIT_CURSOR ) );
                   theCompiler.compile( fileToCompile );
                // When compilation is complete, the Compiler
                // object will callback on the method compileComplete
                // The Compiler runs its own Thread so this method
                // will complete immediately and the outputWindow
                // update can occur.
       private String filename;                                             // the filename as a String
       private JTextArea outputWindow;                                   // the window containing the messages                         
       private Compiler theCompiler;                                        // the compiler
        * Method called by the Compiler when it has completed
        * @param status A CompilerStatus object that contains
        *    the exit value from the compiler
        *    (indicating success or failure) value == 0 => OK and value != 0 => error
        *    and an appropriate text message
       public void compileComplete( CompilerStatus status )
          setCursor( new Cursor( Cursor.DEFAULT_CURSOR ) );
          if( status.exitValue == 0 )
             outputWindow.setBackground( new Color( 0.85F, 1.0F, 0.85F ) );
                                         // pale green
          else
             outputWindow.setBackground( new Color( 1.0F, 0.85F, 0.85F ) );
                                         // pale red
          outputWindow.setText( status.outputString );
    }This is taken straight from my IDE; you'll have to adapt it slightly to make it into a seperate application

  • Java language enhancement for method and field

    similar to the way FooClass.class works in the language, i would like to see the following code constructs also supported by the java language:
    [FooClass.]someMethod.method
    [FooClass.]someField.field
    i thought i had read that something like this was coming in se 7, but i can't seem to find the "what's new in se 7" page. can anyone direct me to it?
    shackman01

    I haven't read anything about that, at all. but I hope it comes to be

  • Java language unsatisfied link error how to fix

    i get a "java language unsatisfied link error" when trying to get my Weatherlink application to run on my new iMac.  It ran OK on my old one.  Whats up with this?

    Java for OS X 2014-001

  • About comma and assotiation in Java language

    I have the next code:
    method(in.readUTF(), in.readLong());What will be read the first and what will be read the second: String or long?
    Does java language tell us something about it? Is it jvm independent?
    thank you.

    I have the next code:
    method(in.readUTF(), in.readLong());What will be read the first and what will be read the
    second: String or long?
    Does java language tell us something about it? Is it
    jvm independent?
    thank you.String first, long second. It's in fact jvm independent.
    Message was edited by:
    Ruly-o_O

  • Super class for java Language

    which is the super class for java Language...
    this is an interview question .
    I SAY Object is the super class for java Language ...
    then he asked whether object class will extend ??
    i say Yes it will implectly extend ...
    then he whether each and every class will extend object
    i say yes ...
    then he asked multiple inheritance is possible in java ...
    i say no ...
    then how will say object class will extend in each and every class....
    hai friends if there is any solution tell mem
    by
    dhana

    which is the super class for java Language...
    this is an interview question .
    I SAY Object is the super class for java Language
    ge ...If you mean the ultimate parent of all classes, yes.
    (Although it's not the parent of interfaces.)
    then he asked whether object class will extend ??
    i say Yes it will implectly extend ...Not sure what is meant by "will object extend."
    then he whether each and every class will extend
    object
    i say yes ...Correct.
    then he asked multiple inheritance is possible in
    java ...
    i say no ...Correct. At least in the usual sense. When people talk about multiple inheritance, the usually mean multiple inheritance of implementation, such as C++ supports. The ability to implement more than one interface in Java is sometimes referred to as multiple inheritance of interface. I don't know if that term is in common use outside of Java.
    then how will say object class will extend in each
    and every class....
    hai friends if there is any solution tell memMultiple inheritance means that a class' ancestors are not all in a straight line to the ultimate parent. That is, not all ancestors are parents or children of each other.
    You are you father's son, and he is his father's son, and so on. So your grandfather is your ancestor, and so is your father. This is not MI.
    You also have a mother. She's neither an ancestor nor a descendant of your father. That's MI.

  • Java Language problem: Multiple interfaces extension.

    Not just any interfaces. Take a close look:
    public interface interface1 {
         public void aMethod();
    public interface Interface2 {
         public void aMethod() throws Exception();
    }As you can see, both interfaces define a single method with the same signature... but one of them throws Exception.
    Consider "merging" these two interfaces:
    public interface Interface3 extends Interface1, Interface2 {}Should the resulting method throw Exception? Eclipse says it does. But I think it shouldn't. Here's the logic:
    If the method in Interface3 DIDN'T throw Exception, it would be able to extends the method in Interface1 and Interface2, because it is not throwing checked exceptions not thrown in the superinterfaces' methods definitions... however, as It DOES throw Exception, it can't extend the method in Interface1, because Interface1's method doesn't throw Exception. Am I right?

    It's not a naming problem. I'll tell you where the problem comes from:
    I'm working with EJBs. I (personally) like to separete the business "signatures" of the beans in a single interface.
    So, for every bean I make, I have a single interface that defines the method.... it says NOTHING about the beans.
    Remote beans methods have to throw RemoteException, so I have to throw RemoteException in my business logic classes. I then make two interfaces that implement this interface. One remote (that just extends this interface and EJBRemote) and another local that extends EJBLocal and overrides all the methods so they don't throw RemoteExceptions (Local bean interfaces' methods must NOT throw RemoteException).
    For example:
    public interface Beaninterface {
    public void aMethod() throws RemoteExeption();
    public interface Bean extends EJBRemote, BeanInterface {}
    public interface BeanLocal extends EJBLocalObject , Beaninterface {
    public void aMethod();
    }No problem so far.
    Here's where the mess comences:
    I want to EXTEND this bean interfaces so I make a bean based on the former.
    I will add another method to the business interface of the new bean:
    Business Interface
    public interface ExtendedBeanInterface extends BeanInterface {
    public void newMethod() throws RemoteException;
    }This new interface defines the new method and inherits the method from BeanInterface
    Remote Interface of the new bean:
    public interface ExtendedBean extends ExtendedBeanInterface, EJBObject {}Nothing wo do there.
    Here is the real problem:
    I have to extend the ExtendedBeanInterface, but that will bring two methods that throw Remote Exception. I have no problem overriding both methods in this interface.. but how about if thyere are 50 methods in the BeanInterface? I'm not going to go ahead and removing each method for evety bean I extend. That makes NO sense. What I think I should do is to extend BeanLocal so those methods that were brought from BeanInterface be known not to throw RemoteExeption.
    public interface ExtendedBeanLocal extends EJBLocalObject, ExtendedBeanInterface, BeanLocal {
    public void newMethod();
    }And THERE is where I hit the wall, because when I deploy the bean, the application server informs me that the resulting interface is throwing RemoteException (courtesy of ExtendedBeanInterface).
    Accoring to my logic about Java Language, by extending BeanLocal, aMethod() shouldn't throw RemoteException as a result in ExtendedBeanLocal.
    So... what is the next step? Go with JCP?

Maybe you are looking for

  • Use ar_receipt_api_pub create_cash API across multiple oper units

    Hi, I have a requirement to create AR receipts across multiple operating units and I am using the AR_RECEIPT_API_PUB's create_cash() to do that. The APIs work fine and I can create receipt in oper unit A. But when I changed to a different operating u

  • View or Query

    I am very inexperienced with LS (second attempt after looking a few years ago). I have watched many video tutorials which has got me very motivated to give it a nother go but I am failing at the first hurdle. I have an existing DB in SQl2008 for CLIE

  • Mapping Node and Attributes

    Hello all,             I am using Process Composer for a process design. I have a human activity and an automated acitivity. Human Activity                                                 Automated Activity + Type Code (node)---- Type Code (node)   

  • Phone will not backup in order to perform iOS 5 update

    I have been trying dice 1pm EST today to update my iPhone and it will not complete backup. It started once and set for over an hour and then just stopped and it has currently been on the " backing up iPhone" screen for almost 2 hours and it's not eve

  • Macbook air slow and sluggish on itunes and safari

    Hi guys, I have the 11 inch macbook air with 1.4 ghz 2gigs of Ram and i must say looking through itunes store - simply scrolling up and down through content is very sluggish, slow and jerky, the same applies for certain websites. Its very laggy scrol