Java VM bug?

Dear all,
I have observed this instance where my JVM implementation behaves in
a manner that appears inconsistent.
The following lines of code all compile:
long a = Long.parseLong("5L");
Long a1 = new Long("5L");
Long a2 = Long.valueOf("5L");
float b = Float.parseFloat("5f");
Float b1 = new Float("5f");
Float b2 = Float.valueOf("5f");
However, at run time a NumberFormatException is thrown at every
one of the first three lines because the JVM does not accept the suffix
"L" in a String number description.
Ok, fair enough!
But why is that rule not enforced for the Float class ( the next three
lines of code do not throw any exceptions, which shows that in this
case the suffix "f" is recogined in the String for what it is)?
Is this a bug or inconsistency?
Or is there a good reason for it?
Thanks
Jorge

In the code of java.lang.FloatingDecimal you can find:
          * We parsed everything we could.
          * If there are leftovers, then this is not good input!
         if ( i < l &&
                ((i != l - 1) ||
                (in.charAt(i) != 'f' &&
                 in.charAt(i) != 'F' &&
                 in.charAt(i) != 'd' &&
                 in.charAt(i) != 'D'))) {
                break parseNumber; // go throw exception
            }

Similar Messages

  • Java Embedding bug in SOA Suite 11g BPEL??

    I am beginning to wonder if there is a 'bug' in the SOA Suite 11g, BPEL, Java Embedding activity? Need some help as soon as possible – does the Java Embedding activity work in SOA Suite 11g?
    Have tried the following on Jdev 11.1.1.1 and Jdev 11.1.1.3 – get the same error message (see below for error message).
    Thanks for any help - Casey
    I created a simple composite app by:
    1.     Created a Composite with BPEL Process
    2.     Created a BPEL variable by the name of Variable and a Simple Type of string      ({http://www.w3.org/2001/XMLSchema}string)
    3.     Added an Assign activity (Assign_1) and assigned the value of “Test Var” to the variable Variable using a Copy operation.
    4.     Then, after the assign activity, added a Java Embedding activity (Java_Embedding_1) with Java Version set to 1.5 and the following code:
    +try{+*
    String var;*
    var=(String)getVariableData(Variable);*
    System.out.println(var);*
    +}  // end try+
    +catch(Exception ex){+*
    System.out.println(ex.getMessage());*
    +}// end catch+
    Compiled and got the following error message:
    Error(23,34): Failed to compile bpel generated classes.*
    failure to compile the generated BPEL classes for BPEL process "BPELProcess1" of composite "default/Project1!1.0"*
    The class path setting is incorrect.*
    Ensure that the class path is set correctly. If this happens on the server side, verify that the custom classes or jars which this BPEL process is depending on are deployed correctly. Also verify that the run time is using the same release/version.*
    Code for the BPEL component is:
    +<?xml version = "1.0" encoding = "UTF-8" ?>+
    +<!--+
    +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+
    Oracle JDeveloper BPEL Designer
    Created: Tue Nov 09 13:01:49 CST 2010
    Author:
    Purpose: Asynchronous BPEL Process
    +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+
    -->
    +<process name="BPELProcess1"+
    targetNamespace="http://xmlns.oracle.com/TestgetVariable_jws/Project1/BPELProcess1"
    xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:client="http://xmlns.oracle.com/TestgetVariable_jws/Project1/BPELProcess1"
    xmlns:ora="http://schemas.oracle.com/xpath/extension"
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/file/TestgetVariable/Project1/FileW"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    +<!--+
    +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+
    PARTNERLINKS
    List of services participating in this BPEL process
    +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+
    -->
    +<partnerLinks>+
    +<!--+
    The 'client' role represents the requester of this service. It is
    used for callback. The location and correlation information associated
    with the client role are automatically set using WS-Addressing.
    -->
    +<partnerLink name="bpelprocess1_client" partnerLinkType="client:BPELProcess1" myRole="BPELProcess1Provider" partnerRole="BPELProcess1Requester"/>+
    +</partnerLinks>+
    +<!--+
    +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+
    VARIABLES
    List of messages and XML documents used within this BPEL process
    +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+
    -->
    +<variables>+
    +<!-- Reference to the message passed as input during initiation -->+
    +<variable name="inputVariable" messageType="client:BPELProcess1RequestMessage"/>+
    +<!-- Reference to the message that will be sent back to the requester during callback -->+
    +<variable name="outputVariable" messageType="client:BPELProcess1ResponseMessage"/>+
    +<variable name="Variable" type="xsd:string"/>+
    +</variables>+
    +<!--+
    +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+
    ORCHESTRATION LOGIC
    Set of activities coordinating the flow of messages across the
    services integrated within this business process
    +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+
    -->
    +<sequence name="main">+
    +<!-- Receive input from requestor. (Note: This maps to operation defined in BPELProcess1.wsdl) -->+
    +<receive name="receiveInput" partnerLink="bpelprocess1_client" portType="client:BPELProcess1" operation="process" variable="inputVariable" createInstance="yes"/>+
    +<!--+
    Asynchronous callback to the requester. (Note: the callback location and correlation id is transparently handled using WS-addressing.)
    -->
    +<assign name="Assign_1">+
    +<copy>+
    +<from expression='"test var"'/>+
    +<to variable="Variable"/>+
    +</copy>+
    +</assign>+
    +<bpelx:exec name="Java_Embedding_1" version="1.5" language="java">+
    +<![CDATA[/*Write your java code below e.g.+
    +     System.out.println("Hello, World");+
    +*/+
    +try{+
      +String var;+
      +var=(String)getVariableData(Variable);+
      +System.out.println(var);+
    +} // end try+
    +catch(Exception ex){+
    System.out.println(ex.getMessage());
    +}// end catch]]>+
    +</bpelx:exec>+
    +<invoke name="callbackClient" partnerLink="bpelprocess1_client" portType="client:BPELProcess1Callback" operation="processResponse" inputVariable="outputVariable"/>+
    +</sequence>+
    +</process>+

    Java Embedding bug in SOA Suite 11g BPEL??

  • Java PDK Bugs and Issues

    Here are some bugs and issues I've run across using the JPDK that I thought other
    developers should be aware of. The following information comes from using JPDK
    1.1 with Oracle Portal Version 3.0.6.3.3 Early Adopter on Windows 2000.
    1) Do not use a colon character (':') in the String value returned by the method getTitle( Locale l ) in the class Portlet. Registering the provider will appear to succeed, but when you view the Portlet Repository you will get the following error message:
    An Unhandled Exception has occurred. ORA-06502: PL/SQL: numeric or value error:
    character to number conversion error
    Your provider and its portlets will not appear in the Portlet Repository when this error occurs.
    Perhaps other characters will cause this error as well.
    2) The Provider class method initSession() is supposed to propagate the array of returned Cookies back to the browser. The Cookies are never propagated to the browser. This is a huge road-block for our application and we need to have this problem fixed as there is no workaround.
    3) There is a limit to the number of portlets you can have per provider. I initially wrote a provider class that managed 19 portlet classes. However, after registering the provider only 17 portlet classes were loaded by the provider and/or displayed by the Portlet Repository. I had to create a second provider to manage additional portlets. The second provider worked out fine for me because I have 5 portlets that are for "administrator" users only. Moving these portlets left 14 portlets for the first provider to manage.
    Note: I don't know if this error occurs using the provider.xml method of implementing a provider and its portlets. My provider and portlets are implemented directly using the Java class API's.
    4) Sometimes I will receive the error "Meta data missing for portlet ID=<number>" when a portlet is rendered for the first time. This error does not occur often but when the error happens two conditions are met:
    a) The portlet is being rendered for the first time
    b) The HTTP and Web Assistant NT services have recently been started.
    This error is obviously caused by some timeout but increasing the timeout values
    for both the provider and the portlet has no effect. This error may be restricted to the NT platform.
    The following notes are not bugs but issues to be aware of:
    1) Make sure you have the "sessiontimeout" parameter defined when declaring the initArgs of a servlet in the zone.properties file and you intend to register your provider with a "Login Frequency" of "Once per User Session". For example:
    servlet.urlservlet.initArgs=debuglevel=1,sessiontimeout=1800000
    If you leave off the session timeout, Oracle Portal will call your provider's initSession() method for every request constantly generating new a session ID.
    2) Currently there is no means to check whether a ProviderUser has administrative
    privileges. This feature would be extremely helpful for restricting which portlets a user has access to when the provider's getPortlets() method is called.
    3) Currently there is no Java API for storing user and global preferences in the
    Oracle database. The JPDK provides a PersonalizationManager class but the method
    of storing the preferences needs to be implemented by the developer.
    The default Personalization Manager persists user preferences as a file
    to disk. However, this method opens up security holes and hinders scaleability.
    We got around the security and scalability issues by using Oracle's JDBC
    driver to persist user and global preferences to custom tables in the underlying Oracle database.
    I would appreciate hearing from anyone who has run across the cookie propagation issue and has any further insights.
    Thanks...
    Dave White
    null

    David,
    Thank you for your feedback on the JPDK. The information you provide helps us understand how customers are using 9iAS
    Portal and its development kits. I apologize for the delay in getting back with you. Since you are using the Early Adopters
    release, we wanted to test a few of the bugs and issues on the production release of 9iAS Portal.
    1) Using a colon character (:) in the String value returned by the method getTitle(Locale l) returned the ORA-06502 error is a
    known issue. This issue actually occurs within 9iAS Portal and should be resolved in the first maintenance release scheduled
    for 9iAS Portal.
    Waiting on reply from Nilay on #1
    2) The Provider class method initSession() not propagating the array of returned cookies back to the browser is an issue that we are currently working on. This bug has been fixed for most cases in the first maintenance release. A 100% fix of this issue is still being worked on.
    3) The limit to the number of portlets you can have per provider was an issue in the Early Adopter release, but is no longer an issue with 9iAS Portal production. Upgrade to the production release and you should no longer see this problem.
    4) The error "Meta data missing for portlet ID=<number>". I have not seen or heard about others receiving this same message. For this error, can you upgrade to the production version and let me know if you still receive this error message. At that time we can check for differences within the configuration.
    Not bug, but issues......
    1) You have made a good point with the sessiontimeout parameter. The JPDK uses servlet 2.0 APIs which does not provide access to the sessiontimeout. Currently, you will need to specify the sessiontimeout parameter in the zone.properties file.
    2) This is true. Currently there is no means to check whether a ProviderUser has administrative privileges. This is on our features list for future enhancements.
    3) This is also true. The DefaultPortletPersonalizationManager was created as a default runtime for developers not used to writing portlet code. It allows developers to write portlet code without concentrating on the underlying framework. Once a developer becomes more experienced with the JPDK and portlet environment, we encourage them to create their own
    customization manager. This includes changing how the portlet repository is stored or changing how the user customization is
    handled and where it is stored. You have no limitations as long as you follow the guidelines of the PortletPersonalizationManager interface.
    I hope this information helped. Again, we appreciate and welcome this type of feedback, it helps us not only locate bugs and issues, but also helps prioritize our enhancement list.
    Sue

  • Java Servlet BUG (Possibly)-Servlet classname replaces retrieved doc name

    I created a test servlet (TestServlet.java) which reads data from a file which could be pdf/doc/xls/zip etc and presents the file to the user for download. When the user clicks on the save option to save the file the default name before the file extension of the file in the save dialog box is always TestServlet. i.e. If the file being downloaded is BEA.doc the default name in the save dialog box is TestServlet.doc
    The contents of the file(data in the file) are correct but the default name should be BEA.doc and not TestServlet.doc. I get the same result if the file is a pdf/xls or any other file type which is being downloaded.
    We tested this in BEA Weblogic 8.1 and Tomcat and get the same results both places so this issue is not application server specific and seems like a bug to us.
    The TestServlet.java file is below
    package com.test;
    import java.io.*;
    import java.util.*;
    import javax.servlet.http.*;
    public class TestServlet  extends HttpServlet
        private String fileName = "c:/BEA.doc";
        private FileInputStream  rd;
        private ByteArrayOutputStream wr;
        byte[] buf = new byte[8192];    //buffer size
        byte[] fileData;
        public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
            doPost(request,response);     
        public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
            int count = 0;
            try
                File theFile = new File(fileName);
                if (theFile.exists())
                    try
                        rd = new FileInputStream(fileName);
                        wr = new ByteArrayOutputStream();
                        while ((count = rd.read(buf)) > -1)
                            wr.write(buf, 0, count);
                        rd.close();                   
                        fileData = wr.toByteArray();
                        response.setContentType("application/msword");
                        OutputStream sos = response.getOutputStream();
                        sos.write(fileData);
                        sos.flush();
                        sos.close();                  
                    catch(Exception ex)
                        System.out.println(ex.getMessage());
                else
                    response.setContentType("text");
                    response.getWriter().write("no data");
            catch (Exception e)
                e.printStackTrace();       
    } I get the same results. i.e. The name of the document downloaded by the servlet is TestServlet.doc instead of BEA.doc which is what I have in c:\BEA.doc.

    The web browser downloading this knows nothing about the file you are loading from disk and sending via the servlet. All it knows is that it requested via Http on the url TestServlet, and is getting something in return.
    A quick google pulled up this link: http://builder.com.com/5100-6370-1027645.html
    You might try this:
    response.setHeader("Content-Disposition","inline;filename=\"BEA.doc\"");
    good luck,
    evnafets

  • Java URL bug

    I guess this is a bug in java.
    I tried opening a page : http://nds1.nds.nokia.com/uaprof/N3250r100.xml. The page has UAProf info of Nokia 3250. It works and opens fine.
    However the page http://nds1.nds.nokia.com/ does not. If you tried opening it from browser (Mozilla) it returns page not found and specifically says "The requested object does not exist on this server. The link you followed is either outdated, inaccurate, or the server has been instructed not to let you have it."
    While trying to open the page with the following snippet
    profile="http://nds1.nds.nokia.com/uaprof/N3250r100.xml";
    URL url = new URL(profile);
    SAXReader reader = new SAXReader();
    Document doc = reader.read(url);
    It throws an UnknownHostException.
    How can I fetch this page without havign this error, there shld be a way to bye pass this.

    I am behind a proxy but i think java uses my default browser setting to connect to the internet.
    If it does not, that's still a bug in java, it shld b able to detect default browser settings. However, atleast if it can't it should allow setting the proxy server and port.
    Any idea as to how to make this config?
    Note: The unknown host exception is complainin about the host http://nds1.nds.nokia.com which I cannot access too from the browser.
    Thnx.
    Message was edited by:
    lekkie.aydot

  • BUG: Oracle Java Compiler bug with anonymous inner classes in constructor

    The following code compiles and runs just fine using 1.4.2_07, 1.5.0_07 and 1.6.0_beta2 when compiling and running from the command-line.
    It does not run when compiling from JDeveloper 10.1.3.36.73 (which uses the ojc.jar).
    When compiled from JDeveloper, the JRE (both the embedded one or the external 1.5.0_07 one) reports the following error:
    java.lang.VerifyError: (class: com/ids/arithmeticexpr/Scanner, method: <init> signature: (Ljava/io/Reader;)V) Expecting to find object/array on
    stack
    Here's the code:
    /** lexical analyzer for arithmetic expressions.
    Fixes the lookahead problem for TT_EOL.
    public class Scanner extends StreamTokenizer
    /** kludge: pushes an anonymous Reader which inserts
    a space after each newline.
    public Scanner( Reader r )
    super( new FilterReader( new BufferedReader( r ) )
    protected boolean addSpace; // kludge to add space after \n
    public int read() throws IOException
    int ch = addSpace ? ' ' : in.read();
    addSpace = ch == '\n';
    return ch;
    public static void main( String[] args )
    Scanner scanner = new Scanner( new StringReader("1+2") ); // !!!
    Removing the (implicit) reference to 'this' in the call to super() by passing an instance of a static inner class 'Kludge' instead of the anonymous subclass of FilterReader fixes the error. The code will then run even when compiled with ojc. There seems to be a bug in ojc concerning references to the partially constructed object (a bug which which is not present in the reference compilers.)
    -- Sebastian

    Thanks Sebastian, I filed a bug for OJC, and I'll look at the Javac bug. Either way, OJC should either give an error or create correct code.
    Keimpe Bronkhorst
    JDev Team

  • How to work around the java runtime bug -The indentation is overridden

    Hello all,
    I generate xml from a servlet and stream to client as the following code. It works fine in my local machine (The xml is indented nicely) but when the war file deployed on a geronimo server 2.0.2. (It uses java 1.5.0_16). The xml streamed out without indentation
                   response.setContentType("application/xml");
                   response.setHeader("Content-disposition","attachment; filename="+fileName);
                   // set up a transformer
                   TransformerFactory transfac = TransformerFactory.newInstance();
                   Transformer trans = transfac.newTransformer();
                   trans.setOutputProperty(OutputKeys.METHOD, "xml");                
                   trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                   trans.setOutputProperty(OutputKeys.STANDALONE, "yes");
                   trans.setOutputProperty(OutputKeys.VERSION, "1.0");
                   trans.setOutputProperty(OutputKeys.INDENT, "yes");
                   trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
                   // create string from xml tree
                   DOMSource source = new DOMSource(doc);
                   ServletOutputStream os = response.getOutputStream();
                   OutputStreamWriter w = new OutputStreamWriter(os, "UTF-8");
                   StreamResult result = new StreamResult();          
                   result.setWriter(w);
                   trans.transform(source, result);This is the bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6337981 (The indentation is overridden)
    I tried the work around suggested there by using OutputStreamWriter, it doesn't help.
    (I cannot change anything on the server. I have to accept whatever in the server)
    Please help
    Thank you
    Edited by: mycoffee on Jun 10, 2011 8:16 AM

    You have to set the indent level on the factory, see bug #6296446. This only affects 1.5; 1.6 allows you to set the indent level on the transformer, as you did (and for cross-version compatibility, setting it on both doesn't hurt).
    transfac.setAttribute("indent-number", Integer.valueOf(4));

  • Reinstall JAVA Environment BUG 1955536

    We have to migrate a production database from 8.1.6 to 8.1.7.
    The new environment should include the XML Parser.
    So we found that when you go into problems with installation of
    JVM it's not possible to remove the JVM by rmjvm.sql
    BUG 1955536.
    Oracle suggestion: Rebuild your database.
    Is it realy true ?
    is anybody expierenced with removing JVM?
    Thanks.

    You need to uninstall jre too. After uninstalling it, delete the files in program files\java and again install j2sdk1.3.

  • Quicktime Java install bug?

    I've been trying to run this Java app that runs on pretty much every other Windows XP machine except mine; on my machine the app starts and then whines about something on the classpath: QTJava.zip. My machine happens to be the only that I've tried that has QT7 on it, in fact I've installed, uninstalled, and reinstalled QT7. I read on a mailing list that:
    "You can't just download QTJava.zip and put it into your classpath. You need to reinstall Quicktime to enable Quicktime for Java. If
    you just put QTJava.zip you will still get errors about your classpath, even though it's correct - that's because QTJava needs a dll to be installed and some stuff in the registry."
    It looks like the QT7 installer or uninstaller didn't do something correctly because my QT7 install seems to work fine although this is the first time I've ever had this bug and I've had QT on my machine for over a year. Has anybody else's classpath been infected by this bug?

    I do have the same problem did you find something about it?

  • Java in Bug Toolkit

    Has the Java functionality in Bug Toolkit affected your search capabilities when searching for bugs?

    have u copied soure files to src folder
    and defined midlet and it's class under seetings tab?

  • Java Editor bug ??

    Is anyone aware that you can do the following in the code
    editor
    int myInt = 10;
    myint.toString();
    it won't compile but the code insight appears when typing
    myInt. and it's treated as an object.

    While developing a java program the editor is not able to ascertain the type of myint, thus, it is given the default type Object. Compilation produces an error, because a variable of type int does not have the toString() method.

  • Standalone Builder java Error/Bug

    Hi,
    I am trying to develop an app with FlexSDK 4.1 using pure AS3. When I try to compile the application using the packager, the following exception in packager procces occurs:
    thread "main", java.lang.Error - unable to find named traits: mx.collections.errors:: ItemPendingError
    at adobe.abc.Domain.resolveTypeName(Domain.java::195)
    ... etc...
    I am using some FXG's instead of classic Flash IDE vector graphics, so I think this might be the problem. Additionally - I am not using my own Apple Dev cert's, but rather some downloaded form the internet (just for try). On the other hand, the apps can be compiled using only the Flash IDE and this certificates.
    I am calling pfi with these parameters:
    call pfi -package -target ipa-test -provisioning-profile "cert/mobileprovision.mobileprovision" -storetype pkcs12 -keystore "cert/cert.p12" -storepass pass "bin/app.ipa" "app-app.xml" "bin/app.swf" "icons/icon29.png" "icons/icon57.png" "icons/icon48.png"
    using this app-app.xml descriptor file:
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://ns.adobe.com/air/application/2.0">
    <id>com.scrape.App</id>
    <filename>App</filename>
    <name>App</name>
    <version>1.0.0</version>
    <description>A small app</description>
    <copyright>Scrapeapps 2011</copyright>
    <initialWindow>
    <renderMode>gpu</renderMode>
    <content>bin/App.swf</content>
    <fullScreen>true</fullScreen>
    <aspectRatio>portrait</aspectRatio>
    <autoOrients>false</autoOrients>
    <x>0</x>
    <y>0</y>
    </initialWindow>
    <supportedProfiles>mobileDevice</supportedProfiles>
    <icon>
    <image29x29>icons/icon29.png</image29x29>
    <image57x57>icons/icon57.png</image57x57>
    <image48x48>icons/icon48.png</image48x48>
    </icon>
    </application>
    Does someone know, where is the problem?
    Thanks

    See Note:464674.1

  • Java/Netbeans BUG? -- Conditional declaration of array

    I think Netbeans (or Java itself?) has a major flaw in its compiler design.
    Explain to me why the following code is not compilable. Specifically, why it should complain about line 8:
    cannot find symbol
    symbol : variable Selected
    When I clearly declared it a couple lines above it!
    Now the fact that it was declared in an "If" clause is a lame excuse, because there is an unconditional Else clause which ALSO declares the same Object array. So either way, the Object array gets declared exactly ONCE. Not zero, not twice. In
    EVERY SINGLE LOGICAL CASE.
    So why was someone on crack when they designed Java/Netbeans? This is a BS error.
    1     if (president.compareTo("Bush") == 0) {
    2           Object Selected[] = listWarCriminals.getSelectedValues();
    3       }
    4       else {
    5           Object Selected[] = listPresidents.getSelectedValues();
    6       }
    7
    8       for (int n=0; n<Selected.length; n++) {
    9           name = Selected[n].toString();
    10          JOptionPane.showMessageDialog(frame, name, "Result", JOptionPane.INFORMATION_MESSAGE);
    11      }

    I think Netbeans (or Java itself?) has a major flaw
    in its compiler design.
    Explain to me why the following code is not
    compilable. Specifically, why it should complain
    about line 8:
    cannot find symbol
    symbol : variable Selected
    When I clearly declared it a couple lines above it!
    Now the fact that it was declared in an "If" clause
    is a lame excuse, because there is an unconditional
    Else clause which ALSO declares the same Object
    array. So either way, the Object array gets declared
    exactly ONCE. Not zero, not twice. In
    EVERY SINGLE LOGICAL CASE. It's not in the least bit a lame excuse. The variable "Selected" is scoped to live only within those two conditional statements. The compiler has behaved exactly as it should. If you want that variable used elsewhere, it needs to be declared in the correct scope. Else clauses are not unconditional, they are evaluated when the corresponding 'if' condition isn't met
    While the object might well definately be created one way or another in this instance, the compiler has no way of knowing that. You could easily adjust the conditions so that it doesn't, but the structure of the code itself - which is what the compiler looks at, not the content - would be exactly the same

  • Is it a Java Date bug?

    Please take a look at below code:
    public class Test {
         public static void main(String[] args) {
              Calendar c1 = Calendar.getInstance();
              c1.set(2000, 0, 1, 1, 0, 0); //2000-01-01 01:00:00
              long l1 = c1.getTimeInMillis();
              Calendar c2 = Calendar.getInstance();
              c2.set(2000, 0, 1, 0, 0, 0); //2000-01-01 00:00:00
              long l2 = c2.getTimeInMillis();
              if (l1 > l2) {
                   System.out.println("true");
              Date d = new Date();
              SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
              d.setTime(l1);
              System.out.println(df.format(d));
              d.setTime(l2);
              System.out.println(df.format(d));
    The output of this program is:
    true
    2000-01-01 01:00:00
    2000-01-01 12:00:00
    Isn't this output weird? The first date should be 1 hour later than the second one, but the result is the first one is 11 hour earlier than the second.
    Anyone know why?

    It just adds "am" or "pm" to the date format, but the problem still exists.It is not a problem. This is the correct display as per the "12-hours clock" notation (specified by the "hh" in the SimpleDateFormat); see this [url http://en.wikipedia.org/wiki/12-hour_clock]wikipedia entry, especially the section on "Confusion at noon and midnight"

  • JWS not working after Java updates to JDK 1.6 update 24 (with apache felix)

    Hi,
    I'm currently working on some JWS application, which heavily relies on Apache Felix. It was working spotless until recent security update which comes along with Java 1.6u24. Now my application dies just when Apache Felix is starting to work.
    The exception being thrown is:
    SEVERE: Permission denied: http://felix.extensions:9/META-INF/services/javax.xml.parsers.SAXParserFactory
    java.lang.SecurityException: Permission denied: http://felix.extensions:9/META-INF/services/javax.xml.parsers.SAXParserFactory
         at com.sun.deploy.security.DeployURLClassPath$UrlLoader.findResource(Unknown Source)
         at com.sun.deploy.security.DeployURLClassPath.findResource(Unknown Source)
         at java.net.URLClassLoader$2.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findResource(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader.findResource(Unknown Source)
         at java.lang.ClassLoader.getResource(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader.access$001(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sun.jnlp.JNLPClassLoader.getResource(Unknown Source)
         at java.lang.ClassLoader.getResource(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader.access$001(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sun.jnlp.JNLPClassLoader.getResource(Unknown Source)
         at java.lang.ClassLoader.getResourceAsStream(Unknown Source)
         at javax.xml.parsers.SecuritySupport$4.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.xml.parsers.SecuritySupport.getResourceAsStream(Unknown Source)
         at javax.xml.parsers.FactoryFinder.findJarServiceProvider(Unknown Source)
         at javax.xml.parsers.FactoryFinder.find(Unknown Source)
         at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)     
         at com.sun.javaws.Launcher.executeApplication(Unknown Source)
         at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
         at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
         at com.sun.javaws.Launcher.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    In javaws.policy, java.policy I have set up proper security rules to enable JWS to work out of sandbox by specifying:
    grant {
    permission java.security.AllPermission;
    grant codeBase "http://felix.extensions:9/" {
    permission java.security.AllPermission;
    Also, I'm using maven's webstart-maven-plugin to create a JWS jnlp file. It's being property signed with security certificate. My resulting jnlp file has this part of configuration embedded:
    <security>
    <all-permissions />
    </security>
    Do You have any ideas what might be the problem?
    Cheers

    I just submitted a bug, and got the following e-mail.
    Hope the java guys take a look ...
    Full View
    Your Report (Review ID: 1990127) - SecurityException from all-permissions app - should be ClassNotFoundException
    From:     
    "[email protected]" <[email protected]>
    Add to Contacts
    To:     [email protected]     
    Dear Java Developer,
    Thank you for your interest in improving the quality of Java Technology.
    Your report has been assigned an internal review ID of 1990127, which is NOT visible on the Sun Developer Network (SDN).
    Please be aware that the large volume of reports we receive sometimes prevents us from responding individually to each message.
    If the information is determined to be a new Bug or RFE, or a duplicate of a known Bug or RFE, you will receive a followup email containing a seven digit bug number. You may search for, view, or vote for this bug in the Bug Database at http://bugs.sun.com/.
    If you just reported an issue that could have a major impact on your project and require a timely response, please consider purchasing one of the support offerings described at http://developers.sun.com/services/.
    The Sun Developer Network (http://developers.sun.com) is a free service that Sun offers. To join, visit http://developers.sun.com/global/join_sdn.html.
    Thank you for using our bug submit page.
    Regards,
    Java Developer Bug Report Review Team
    Date Created: Wed Mar 02 15:43:52 MST 2011
    Type: bug
    Customer Name: Reuben Pasquini
    Customer Email: [email protected]
    SDN ID: catdogboy
    status: Waiting
    Category: javawebstart
    Subcategory: other
    Company: http://frickjack.com
    release: 6u24
    hardware: x86
    OSversion: windows_7
    priority: 4
    Synopsis: SecurityException from all-permissions app - should be ClassNotFoundException
    Description:
    FULL PRODUCT VERSION :
    java version "1.6.0_24"
    Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
    Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)
    ADDITIONAL OS VERSION INFORMATION :
    Microsoft Windows [Version 6.1.7600]
    EXTRA RELEVANT SYSTEM CONFIGURATION :
    This is a java bug - I have users on WIndows 7 and XP, and also reported on Apache felix mailing list
    A DESCRIPTION OF THE PROBLEM :
    The following class, when bundled, signed, and deployed with the .jnlp file below, throws a
    SecurityException
    in the new java release - even though the .jnlp specifes "all-permissions".
    Past releases would throw a ClassNotFoundException - which is great,
    and is what things like Oracle's thin-client ojdbc6.jar expect.
    The program bootstraps the Felix OSGi engine - which apparently sets up a URLClassLoader with a custom felix:// URL.
    The output of running the program with webstart follows
    below the .jnlp file.
    Note that this .jnlp file is setup to run off the file system, but the same result follows from web-launched apps, whatever.
    package littleware.demo;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.sql.Connection;
    import java.util.HashMap;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.SwingUtilities;
    import javax.swing.WindowConstants;
    import org.apache.felix.framework.Felix;
    public class JavaToy {
    private static final Logger log = Logger.getLogger( JavaToy.class.getName() );
    public static class AppRunner implements Runnable {
    public void run() {
    final StringWriter swriter = new StringWriter();
    final PrintWriter pwriter = new PrintWriter( swriter );
    pwriter.append( "Class path: " ).append(
    System.getProperty( "java.class.path" )
    ).append( "\n\n-------------------------\n" );
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    if ( classLoader instanceof URLClassLoader ) {
    pwriter.append( "URLClassLoader:\n" );
    for ( URL url : ((URLClassLoader) classLoader).getURLs() ) {
    pwriter.append( url.toString() ).append( "\n" );
    pwriter.append( "\n--------------------------------\n" );
    try {
    Class.forName( "bogus.DoesNotExist" );
    pwriter.append( "No exception thrown on bogus class load\n" );
    } catch ( Exception ex ) {
    pwriter.append( "Caught exception loading bogus class: " ).append( ex.toString() ).append( "\n" );
    ex.printStackTrace(pwriter);
    pwriter.flush();
    final JFrame jframe = new JFrame( "Webstart test" );
    final JTextArea jtext = new JTextArea( swriter.toString(), 20, 40 );
    jframe.add( new JScrollPane( jtext ) );
    jframe.pack();
    jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    jframe.setVisible(true);
    public static void main( String[] args ) {
    try {
    log.log( Level.INFO, "Launching felix!" );
    (new Felix(new HashMap<String, Object>())).start();
    Thread.sleep( 2000 );
    } catch (Exception ex) {
    log.log(Level.SEVERE, "Caught exception", ex);
    System.exit(0);
    SwingUtilities.invokeLater( new AppRunner() );
    REGRESSION. Last worked in version 6
    STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
    *. Download felix.jar from
    http://felix.apache.org
    *. Build the following code, sign Toy.jar and felix.jar with your key,
    launch with the following .jnlp or something similar ....
    package littleware.demo;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.sql.Connection;
    import java.util.HashMap;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.SwingUtilities;
    import javax.swing.WindowConstants;
    import org.apache.felix.framework.Felix;
    public class JavaToy {
    private static final Logger log = Logger.getLogger( JavaToy.class.getName() );
    public static class AppRunner implements Runnable {
    public void run() {
    final StringWriter swriter = new StringWriter();
    final PrintWriter pwriter = new PrintWriter( swriter );
    pwriter.append( "Class path: " ).append(
    System.getProperty( "java.class.path" )
    ).append( "\n\n-------------------------\n" );
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    if ( classLoader instanceof URLClassLoader ) {
    pwriter.append( "URLClassLoader:\n" );
    for ( URL url : ((URLClassLoader) classLoader).getURLs() ) {
    pwriter.append( url.toString() ).append( "\n" );
    pwriter.append( "\n--------------------------------\n" );
    try {
    Class.forName( "bogus.DoesNotExist" );
    pwriter.append( "No exception thrown on bogus class load\n" );
    } catch ( Exception ex ) {
    pwriter.append( "Caught exception loading bogus class: " ).append( ex.toString() ).append( "\n" );
    ex.printStackTrace(pwriter);
    pwriter.flush();
    final JFrame jframe = new JFrame( "Webstart test" );
    final JTextArea jtext = new JTextArea( swriter.toString(), 20, 40 );
    jframe.add( new JScrollPane( jtext ) );
    jframe.pack();
    jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    jframe.setVisible(true);
    public static void main( String[] args ) {
    try {
    log.log( Level.INFO, "Launching felix!" );
    (new Felix(new HashMap<String, Object>())).start();
    Thread.sleep( 2000 );
    } catch (Exception ex) {
    log.log(Level.SEVERE, "Caught exception", ex);
    System.exit(0);
    SwingUtilities.invokeLater( new AppRunner() );
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <jnlp codebase="file:/C:/Users/pasquini/Documents/Code/JavaToy/dist/" href="launch.jnlp" spec="1.0+">
    <information>
    <title>JavaToy</title>
    <vendor>pasquini</vendor>
    <homepage href=""/>
    <description>JavaToy</description>
    <description kind="short">JavaToy</description>
    </information>
    <update check="always"/>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.5+"/>
    <jar href="JavaToy.jar" main="true"/>
    <jar href="lib/felix-2.0.4.jar"/>
    </resources>
    <application-desc main-class="littleware.demo.JavaToy">
    </application-desc>
    </jnlp>
    EXPECTED VERSUS ACTUAL BEHAVIOR :
    EXPECTED -
    Class path: C:\Program Files\Java\jre6\lib\deploy.jar
    URLClassLoader:
    file:/C:/Users/pasquini/Documents/Code/JavaToy/dist/JavaToy.jar
    file:/C:/Users/pasquini/Documents/Code/JavaToy/dist/lib/felix-2.0.4.jar
    http://felix.extensions:9/
    Caught exception loading bogus class: java.lang.ClassNotFoundException: bogus.DoesNotExist
    java.lang.ClassNotFoundException: bogus.DoesNotExist
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at littleware.demo.JavaToy$AppRunner.run(JavaToy.java:39)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    ACTUAL -
    Class path: C:\\Program Files (x86)\\Java\\jre6\\lib\\deploy.jar
    URLClassLoader:
    file:/C:/Users/pasquini/Documents/Code/JavaToy/dist/JavaToy.jar
    file:/C:/Users/pasquini/Documents/Code/JavaToy/dist/lib/felix-2.0.4.jar
    http://felix.extensions:9/
    Caught exception loading bogus class: java.lang.SecurityException: Permission denied: http://felix.extensions:9/bogus/DoesNotExist.class
    java.lang.SecurityException: Permission denied: http://felix.extensions:9/bogus/DoesNotExist.class
    at com.sun.deploy.security.DeployURLClassPath$UrlLoader.getResource(Unknown Source)
    at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at littleware.demo.JavaToy$AppRunner.run(JavaToy.java:39)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    REPRODUCIBILITY :
    This bug can be reproduced always.
    ---------- BEGIN SOURCE ----------
    package littleware.demo;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.sql.Connection;
    import java.util.HashMap;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.SwingUtilities;
    import javax.swing.WindowConstants;
    import org.apache.felix.framework.Felix;
    public class JavaToy {
    private static final Logger log = Logger.getLogger( JavaToy.class.getName() );
    public static class AppRunner implements Runnable {
    public void run() {
    final StringWriter swriter = new StringWriter();
    final PrintWriter pwriter = new PrintWriter( swriter );
    pwriter.append( "Class path: " ).append(
    System.getProperty( "java.class.path" )
    ).append( "\n\n-------------------------\n" );
    final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    if ( classLoader instanceof URLClassLoader ) {
    pwriter.append( "URLClassLoader:\n" );
    for ( URL url : ((URLClassLoader) classLoader).getURLs() ) {
    pwriter.append( url.toString() ).append( "\n" );
    pwriter.append( "\n--------------------------------\n" );
    try {
    Class.forName( "bogus.DoesNotExist" );
    pwriter.append( "No exception thrown on bogus class load\n" );
    } catch ( Exception ex ) {
    pwriter.append( "Caught exception loading bogus class: " ).append( ex.toString() ).append( "\n" );
    ex.printStackTrace(pwriter);
    pwriter.flush();
    final JFrame jframe = new JFrame( "Webstart test" );
    final JTextArea jtext = new JTextArea( swriter.toString(), 20, 40 );
    jframe.add( new JScrollPane( jtext ) );
    jframe.pack();
    jframe.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    jframe.setVisible(true);
    public static void main( String[] args ) {
    try {
    log.log( Level.INFO, "Launching felix!" );
    (new Felix(new HashMap<String, Object>())).start();
    Thread.sleep( 2000 );
    } catch (Exception ex) {
    log.log(Level.SEVERE, "Caught exception", ex);
    System.exit(0);
    SwingUtilities.invokeLater( new AppRunner() );
    ---------- END SOURCE ----------
    CUSTOMER SUBMITTED WORKAROUND :
    I can work around the problem by installing the app locally, so web-start is not necessary. I ran into this problem with an app that connects to Oracle via ojdbc6.jar - ojdbc6.jar invokes "Class.forName" to check for optional i18n classes on the class path. The Oracle code correctly handles the correct ClassNotFoundException, but the new SecurityException is breaking my app.
    workaround:

Maybe you are looking for

  • Forms 6i Bad first day of week

    Hello, Please help me We have oracle form 6i application in our organization, in the past we had the same app but the database was 9i (9.2.0.1) and we migrate the database to 10g (10.2.0.1) with the same NLS parameters, the problem is there are forms

  • Mediasource Organizer 3.30.21 Quest

    I have just updated my mediasource organizer to be compatible with my latest firmware update for my 60GB Creative Zen Xtra (2.0.03). However, when I try to explore the content of my jukebox in the organizer, instead of listing the contents on a track

  • I have Photoshop on a CD, how do I install on a computer without CD-rom?

    I Have photoshop on a CD, how do I i stall IT on my nen Apple which does not have a CD reader?

  • Maint. Status problem for View in ABAP Dictionary

    Hello, guys. I have a problem with a configuration in my Maintainence View in the ABAP Dictionary. I have a maintainence view in my abap dictionary, When i go to the tab "Maint. Status" there, and want to change the "Data Browser/Table View Maint." f

  • Kiosk mode with no tool bars or scroll bars

    I have touchscreen information kiosks running Linux. I need a browser that will ONLY display the website: No tool bars, NO scroll bars ALWAYS running full screen. Would it be possible for me, NON programmer to edit config files to achieve this, or do