Strange double calculation result with JDK 1.4.2

Hi,
I've written a small benchmark to test the power of a Sharp Zaurus PDA. Wanting to compare it with my workstation, I ran it on the PC with JDK1.4.2 Beta and was really surprised to discover that the double calculation of Pi gave a non-correct result: Pi = 3.1413934230804443!!!
I've tried to isolate the bug without success at the moment. It only happens when run from the Zjb program in JDK1.4.2, either from the command line or from Eclipse.
The result is correct when run with JDK1.4.1, JDK1.4.1_01, JDK1.1.8 that are also setup on the PC. I extracted the faulty loop and executed the sniplet, but the result is OK. I added the previous lines (running the Ackerman function to test recursivity and stack management): still OK, from Eclipse and command line.
I think the problem must be a configuration one on my computer: a 2xPII 350, Win2K SP3. Perhaps the 1.4.2 JVM is using an old library... I can't imagine that the Beta JVM would have such problem.
Or there is a bug in the program which make the stack or the FPU registers break, but I can't find where: all other platforms I tested gave correct results.
Could someone with a JDK1.4.2 installation test my program and post what were the results for the Pi calculation?
The 10KB source is available on http://www.alterna.tv/zjb/Zjb.java
Thanks.

Yes, it was the Pentium, at the time when 100MHz was top speed...
My CPUs are supposed not to suffer from that old disease.
But if it were the case, new JVM can't drop software patches like this. Today, Intel started again the release of the new P4 at 3GHz, after adding a software patch for the hardware defect they had detected...
I post the code for my small program here as my Web site is frequently down this week:
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.List;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigInteger;
* Zjb: Zaurus Java Bechmark
* @author GenePi
class Zjb
     extends Frame
     static Zjb _mainWindow;
      * Number of benchmark runs.
     private final TextField _runs;
      * Results list
     private final List _results;
      * Wait, program is thinking...
     private final Label _wait;
      * Start button
     private final Button _start;
      * Benchmark running
     private volatile boolean _running = false;
      * Layout the main window.
     Zjb()
          super("Zaurus java benchmark 1.0");
          setLayout(new BorderLayout());
          // Input fields
          Panel top = new Panel(new GridLayout(1, 0));
          top.add(new Label("Number of runs"));
          _runs = new TextField("1");
          top.add(_runs);
          add(top, BorderLayout.NORTH);
          // Results list
          _results = new List();
          add(_results, BorderLayout.CENTER);
          // Start button
          final Panel bottom = new Panel(new FlowLayout(FlowLayout.RIGHT));
          _wait = new Label();
          bottom.add(_wait);
          _start = new Button("Start");
          _start.addActionListener(new ActionListener()
               public void actionPerformed(final ActionEvent evt)
                    if (!_running)
                         // Clear previous results and start benchmark.
                         _results.clear();
                         _start.setLabel("Stop");
                         _wait.setText("Running...          ");
                         bottom.validate();
                         _running = true;
                    else
                         _start.setLabel("Start");
                         _wait.setText("");
                         _running = false;
          bottom.add(_start);
          // Quit button
          final Button quit = new Button("Quit");
          quit.addActionListener(new ActionListener()
               public void actionPerformed(final ActionEvent evt)
                    System.exit(0);
          bottom.add(quit);
          add(bottom, BorderLayout.SOUTH);
          // Exit when main window closes
          addWindowListener(new WindowAdapter()
               public void windowClosing(final WindowEvent evt)
                    System.exit(0);
          Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
          setSize(dim);
          validate();
      * The benchmarks
      * @param runs Number of runs
     private static void runBenchmarks(final int runs)
          long start;
          long end;
          long totalStart;
          long totalEnd;
          // Integer arithmetic
          start = System.currentTimeMillis();
          totalStart = start;
          int resultInt = 0;
          for (int i = 0; i < runs; i++)
               resultInt = ackerman(3, 9);
               // resultInt = ackerman(3, 7);
          end = System.currentTimeMillis();
          _mainWindow._results.add("Integer arithmetic: " + ((end - start) / 1000.0) + " s [Ack(3,9)=" + resultInt + "]");
          if (!_mainWindow._running)
               return;
          // Float and double
          start = System.currentTimeMillis();
          double resultDouble = 0.0;
          for (int i = 0; i < runs; i++)
               resultDouble = 0.0;
               for (int j = 1; j < 1000000; j++)
                    resultDouble += 1.0 / ((double) j * (double) j);
               System.out.println("resultDouble=" + resultDouble);
               resultDouble = Math.sqrt(resultDouble * 6.0);
          end = System.currentTimeMillis();
          _mainWindow._results.add("Double arithmetic: " + ((end - start) / 1000.0) + " s [Pi=" + resultDouble + "]");
          if (!_mainWindow._running)
               return;
          // Big operations
          start = System.currentTimeMillis();
          BigInteger resultBig = new BigInteger("1");
          for (int i = 0; i < runs; i++)
               resultBig = fact(3000);
          end = System.currentTimeMillis();
          _mainWindow._results.add("Infinite arithmetic: " + ((end - start) / 1000.0) + " s [3000!=" + resultBig.toString().substring(1, 20) + "...]");
          if (!_mainWindow._running)
               return;
          // Strings
          start = System.currentTimeMillis();
          String resultString = null;
          for (int i = 0; i < runs; i++)
               final String alphabet = " qwertyuioplkjhgfdsazxcvbnm0789456123./*";
               StringBuffer buf = new StringBuffer();
               for (int j = 0; j < 100000; j++)
                    int pos = j % alphabet.length();
                    buf.append(alphabet.substring(pos, pos + 1));
               resultString = buf.toString();
          end = System.currentTimeMillis();
          _mainWindow._results.add("Strings: " + ((end - start) / 1000.0) + " s [" + resultString.substring(1, 20) + "...]");
          if (!_mainWindow._running)
               return;
          // Drawing
          start = System.currentTimeMillis();
          for (int i = 0; i < runs; i++)
               final int size = 200;
               Dialog dialog = new Dialog(_mainWindow, "Drawing...", true);
               dialog.add(new TestPanel(dialog));
               dialog.setSize(size, size);
               dialog.show();
          end = System.currentTimeMillis();
          _mainWindow._results.add("Drawing: " + ((end - start) / 1000.0) + " s");
          if (!_mainWindow._running)
               return;
          // File copy
          start = System.currentTimeMillis();
          String resultIO = "OK";
          loopIO:
          for (int i = 0; i < runs; i++)
               final String tempName = "/tmp/Zjb.tmp";
               try
                    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempName));
                    for (int j = 0; j < 1000000; j++)
                         out.write((byte) j);
                    out.close();
                    BufferedInputStream in = new BufferedInputStream(new FileInputStream(tempName));
                    for (int j = 0; j < 1000000; j++)
                         int r = in.read();
                         if ((byte) r != (byte) j)
                              resultIO = "Failed";
                              System.err.println("Content mismatch at " + j);
                              break loopIO;
                    in.close();
                    new File(tempName).delete();
               catch(IOException ioe)
                    resultIO = "Failed";
                    System.err.println(ioe);
                    break loopIO;
          end = System.currentTimeMillis();
          _mainWindow._results.add("Files I/O: " + ((end - start) / 1000.0) + " s [1MB written/read/deleted: " + resultIO + "]");
          totalEnd = end;
          _mainWindow._results.add("");
          _mainWindow._results.add("Total: " + ((totalEnd - totalStart) / 1000.0) + " s");
      * Utility functions: Ackerman function
      * @param m
      * @param n
     private static int ackerman(final int m, final int n)
          if (m == 0)
               return (n + 1);
          else if (n == 0)
               return (ackerman(m - 1, 1));
          else
               return ackerman(m - 1, ackerman(m, (n - 1)));
      * Factorial of big numbers.
      * @param n
      * @return
     private static BigInteger fact(final int n)
          final BigInteger one = new BigInteger("1");
          BigInteger num = new BigInteger("1");
          BigInteger fact = new BigInteger("1");
          for (int i = 2; i <= n; i++)
               num = num.add(one);
               fact = fact.multiply(num);
          return fact;
      * Benchmark entry point.
      * @param args Command line arguments
     public static void main(String[] args)
          _mainWindow = new Zjb();
          _mainWindow.show();
          synchronized (Zjb.class)
               while (true)
                    try
                         Zjb.class.wait(500L);
                    catch (InterruptedException ie)
                         // Wake
                    if (_mainWindow._running)
                         try
                              runBenchmarks(Integer.parseInt(_mainWindow._runs.getText()));
                         catch (NumberFormatException nfe)
                              _mainWindow._runs.setText("1");
                              runBenchmarks(1);
                         _mainWindow._running = false;
                         _mainWindow._start.setLabel("Start");
                         _mainWindow._wait.setText("");
class TestPanel
     extends Panel
      * The dialog containing the panel.
     private final Dialog _dialog;
     TestPanel(final Dialog dialog)
          _dialog = dialog;
     public void paint(final Graphics g)
          Dimension dim = getSize();
          g.setColor(Color.white);
          g.fillRect(0, 0, dim.width, dim.height);
          for (int i = 0; i < 1000; i++)
               Color color = new Color((int) (Math.random() * Integer.MAX_VALUE));
               int x = (int) (Math.random() * dim.width);
               int y = (int) (Math.random() * dim.height);
               int width = (int) (Math.random() * dim.width);
               int height = (int) (Math.random() * dim.height);
               g.setColor(color);
               g.fillRect(x, y, width, height);
          g.setColor(Color.white);
          g.fillRect(0, 0, dim.width, dim.height);
          for (int i = 0; i < 1000; i++)
               Color color = new Color((int) (Math.random() * Integer.MAX_VALUE));
               int x = (int) (Math.random() * dim.width);
               int y = (int) (Math.random() * dim.height);
               int width = (int) (Math.random() * dim.width);
               int height = (int) (Math.random() * dim.height);
               g.setColor(color);
               g.fillOval(x, y, width, height);
          // Hide dialog when finished
          _dialog.hide();
}

Similar Messages

  • [svn:bz-trunk] 18926: bug fix BLZ-570 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError

    Revision: 18926
    Revision: 18926
    Author:   [email protected]
    Date:     2010-12-01 14:07:19 -0800 (Wed, 01 Dec 2010)
    Log Message:
    bug fix BLZ-570 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError
    We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml.
    This needs documentation.
    Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
    Modified Paths:
        blazeds/trunk/modules/common/src/flex/messaging/errors.properties
        blazeds/trunk/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.java
        blazeds/trunk/modules/core/src/flex/messaging/io/SerializationContext.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf0Input.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/Amf3Input.java
        blazeds/trunk/modules/core/src/flex/messaging/io/amf/AmfIO.java

  • [svn:bz-4.0.0_fixes] 20451: backporting bug fix BLZ-570/ BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError .

    Revision: 20451
    Revision: 20451
    Author:   [email protected]
    Date:     2011-02-24 08:33:31 -0800 (Thu, 24 Feb 2011)
    Log Message:
    backporting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation.  Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
        http://bugs.adobe.com/jira/browse/BLZ-620
    Modified Paths:
        blazeds/branches/4.0.0_fixes/modules/common/src/flex/messaging/errors.properties
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/endpoints/AbstractEndpoint.j ava
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/SerializationContext.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf0Input.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/Amf3Input.java
        blazeds/branches/4.0.0_fixes/modules/core/src/flex/messaging/io/amf/AmfIO.java

    Dear Pallavi,
    Very useful post!
    I am looking for similar accelerators for
    Software Inventory Accelerator
    Hardware Inventory Accelerator
    Interfaces Inventory
    Customization Assessment Accelerator
    Sizing Tool
    Which helps us to come up with the relevant Bill of Matetials for every area mentioned above, and the ones which I dont know...
    Request help on such accelerators... Any clues?
    Any reply, help is highly appreciated.
    Regards
    Manish Madhav

  • [svn:bz-3.x] 20443: back porting bug fix BLZ-570/ BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error  : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError .

    Revision: 20443
    Revision: 20443
    Author:   [email protected]
    Date:     2011-02-23 21:19:22 -0800 (Wed, 23 Feb 2011)
    Log Message:
    back porting bug fix BLZ-570/BLZ-620 Double linked list with lot of objects result in BlazeDS Error deserializing error : StackOverflowError  We put hard limit to the max object nest level to prevent StackOverFlowError. the default max object nest level is 1024 and it can be configured in the endpoint/serialziation section in service-config.xml. This needs documentation.  Checkintests pass
    Ticket Links:
        http://bugs.adobe.com/jira/browse/BLZ-570
        http://bugs.adobe.com/jira/browse/BLZ-620
    Modified Paths:
        blazeds/branches/3.x/modules/common/src/java/flex/messaging/errors.properties
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/endpoints/AbstractEndpoint.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/SerializationContext.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf0Input.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/Amf3Input.java
        blazeds/branches/3.x/modules/core/src/java/flex/messaging/io/amf/AmfIO.java

  • Strange calculation results

    Hi all,
    The situation is as follows:
    I created a pivot table which shows profits. The measures, which are shown as the columns of the pivot, are 'Sales', 'Costs', 'Profit' (= 'Sales'-'Costs') & %Profit (= 'Profit' / 'Sales'). The left edge of the pivot 'hosts' a 'Products' hierarchy (Category -> Top Group -> Group -> Family -> Item). I also added OBIEE's default summary calculation. While the sums of all the 'normal' measures are calculated fine, the sum of '%Profit' doesn't show the correct results.
    For example (first column is 'Sales', second is 'Cost', third is 'Profit', fourth '%Profit') -
    PROD SALES COST PROFIT %PROFIT
    Prod4 8089.61 5588.80 2501.81 30.93
    Prod2 13111.26 9716.86 3394.40 25.89
    Prod3 4001.14 2746.07 1255.07 31.37
    Prod 27232.92 16476.41 10756.51 39.50
    Prod5 22100.00 14828.77 7271.23 32.90
    Prod6 3581.25 2336.80 1244.45 34.75
    Prod7 11731.10 7750.91 3980.19 33.93
    Total: 89847.28 59443.60 30403.68 33.60
    While the 0.02 incorrectness in the PROFIT column is solved when 5 digits after the point are shown, the % is correct for all the products but not for their summaries (even in the extreme case when the values are shown with 15 digits after the point, just for curiosity).
    Doens anyone have a clue?

    Ha! Rock on, blemmo. :) Glad you found it.
    David
    stiller (at) quip (dot) net
    Dev essays:
    http://www.quip.net/blog/
    "Luck is the residue of good design."
    "blemmo" <[email protected]> wrote in
    message
    news:e6u6rs$a41$[email protected]..
    > d'oh... just realized the numbers came in as strings...
    so it all looked
    > good
    > in the trace, but calculating strings with numbers isn't
    very exact...
    >
    > darn... I should remember to use the debugger more
    often.
    >
    > cheers,
    > blemmo
    >

  • Performance problems with jdk 1.5 on Linux plattform

    Performance problems with jdk 1.5 on Linux plattform
    (not tested on Windows, might be the same)
    After refactoring using the new features from java 1.5 I lost
    performance significantly:
    public Vector<unit> units;
    The new code:
    for (unit u: units) u.accumulate();
    runs more than 30% slower than the old code:
    for (int i = 0; i < units.size(); i++) units.elementAt(i).accumulate();
    I expected the opposite.
    Is there any information available that helps?

    Here's the complete benchmark code I used:package test;
    import java.text.NumberFormat;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.Vector;
    public class IterationPerformanceTest {
         private int m_size;
         public IterationPerformanceTest(int size) {
              m_size = size;
         public long getArrayForLoopDuration() {
              Integer[] testArray = new Integer[m_size];
              for (int item = 0; item < m_size; item++) {
                   testArray[item] = new Integer(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (int index = 0; index < m_size; index++) {
                   builder.append(testArray[index]);
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getArrayForEachDuration() {
              Integer[] testArray = new Integer[m_size];
              for (int item = 0; item < m_size; item++) {
                   testArray[item] = new Integer(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (Integer item : testArray) {
                   builder.append(item);
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getArrayListForLoopDuration() {
              ArrayList<Integer> testList = new ArrayList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (int index = 0; index < m_size; index++) {
                   builder.append(testList.get(index));
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getArrayListForEachDuration() {
              ArrayList<Integer> testList = new ArrayList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (Integer item : testList) {
                   builder.append(item);
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getArrayListIteratorDuration() {
              ArrayList<Integer> testList = new ArrayList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              Iterator<Integer> iterator = testList.iterator();
              while(iterator.hasNext()) {
                   builder.append(iterator.next());
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getLinkedListForLoopDuration() {
              LinkedList<Integer> testList = new LinkedList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (int index = 0; index < m_size; index++) {
                   builder.append(testList.get(index));
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getLinkedListForEachDuration() {
              LinkedList<Integer> testList = new LinkedList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (Integer item : testList) {
                   builder.append(item);
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getLinkedListIteratorDuration() {
              LinkedList<Integer> testList = new LinkedList<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testList.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              Iterator<Integer> iterator = testList.iterator();
              while(iterator.hasNext()) {
                   builder.append(iterator.next());
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getVectorForLoopDuration() {
              Vector<Integer> testVector = new Vector<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testVector.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (int index = 0; index < m_size; index++) {
                   builder.append(testVector.get(index));
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getVectorForEachDuration() {
              Vector<Integer> testVector = new Vector<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testVector.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              for (Integer item : testVector) {
                   builder.append(item);
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
         public long getVectorIteratorDuration() {
              Vector<Integer> testVector = new Vector<Integer>();
              for (int item = 0; item < m_size; item++) {
                   testVector.add(item);
              StringBuilder builder = new StringBuilder();
              long start = System.nanoTime();
              Iterator<Integer> iterator = testVector.iterator();
              while(iterator.hasNext()) {
                   builder.append(iterator.next());
              long end = System.nanoTime();
              System.out.println(builder.length());
              return end - start;
          * @param args
         public static void main(String[] args) {
              IterationPerformanceTest test = new IterationPerformanceTest(1000000);
              System.out.println("\n\nRESULTS:");
              long arrayForLoop = test.getArrayForLoopDuration();
              long arrayForEach = test.getArrayForEachDuration();
              long arrayListForLoop = test.getArrayListForLoopDuration();
              long arrayListForEach = test.getArrayListForEachDuration();
              long arrayListIterator = test.getArrayListIteratorDuration();
    //          long linkedListForLoop = test.getLinkedListForLoopDuration();
              long linkedListForEach = test.getLinkedListForEachDuration();
              long linkedListIterator = test.getLinkedListIteratorDuration();
              long vectorForLoop = test.getVectorForLoopDuration();
              long vectorForEach = test.getVectorForEachDuration();
              long vectorIterator = test.getVectorIteratorDuration();
              System.out.println("Array      for-loop: " + getPercentage(arrayForLoop, arrayForLoop) + "% ("+getDuration(arrayForLoop)+" sec)");
              System.out.println("Array      for-each: " + getPercentage(arrayForLoop, arrayForEach) + "% ("+getDuration(arrayForEach)+" sec)");
              System.out.println("ArrayList  for-loop: " + getPercentage(arrayForLoop, arrayListForLoop) + "% ("+getDuration(arrayListForLoop)+" sec)");
              System.out.println("ArrayList  for-each: " + getPercentage(arrayForLoop, arrayListForEach) + "% ("+getDuration(arrayListForEach)+" sec)");
              System.out.println("ArrayList  iterator: " + getPercentage(arrayForLoop, arrayListIterator) + "% ("+getDuration(arrayListIterator)+" sec)");
    //          System.out.println("LinkedList for-loop: " + getPercentage(arrayForLoop, linkedListForLoop) + "% ("+getDuration(linkedListForLoop)+" sec)");
              System.out.println("LinkedList for-each: " + getPercentage(arrayForLoop, linkedListForEach) + "% ("+getDuration(linkedListForEach)+" sec)");
              System.out.println("LinkedList iterator: " + getPercentage(arrayForLoop, linkedListIterator) + "% ("+getDuration(linkedListIterator)+" sec)");
              System.out.println("Vector     for-loop: " + getPercentage(arrayForLoop, vectorForLoop) + "% ("+getDuration(vectorForLoop)+" sec)");
              System.out.println("Vector     for-each: " + getPercentage(arrayForLoop, vectorForEach) + "% ("+getDuration(vectorForEach)+" sec)");
              System.out.println("Vector     iterator: " + getPercentage(arrayForLoop, vectorIterator) + "% ("+getDuration(vectorIterator)+" sec)");
         private static NumberFormat percentageFormat = NumberFormat.getInstance();
         static {
              percentageFormat.setMinimumIntegerDigits(3);
              percentageFormat.setMaximumIntegerDigits(3);
              percentageFormat.setMinimumFractionDigits(2);
              percentageFormat.setMaximumFractionDigits(2);
         private static String getPercentage(long base, long value) {
              double result = (double) value / (double) base;
              return percentageFormat.format(result * 100.0);
         private static NumberFormat durationFormat = NumberFormat.getInstance();
         static {
              durationFormat.setMinimumIntegerDigits(1);
              durationFormat.setMaximumIntegerDigits(1);
              durationFormat.setMinimumFractionDigits(4);
              durationFormat.setMaximumFractionDigits(4);
         private static String getDuration(long nanos) {
              double result = (double)nanos / (double)1000000000;
              return durationFormat.format(result);
    }

  • XSLT with java extensions not working with jdk 1.6

    Hi,
    in as XSL transformation I'm using java functions in some cases. With jdk1.5 this works fine. But when switching to jdk1.6 it seems the java classes are not properly initialized.
    See following simple XSL:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java">
         <xsl:output method="html" indent="yes" encoding="iso-8859-1"/>
         <xsl:template match="/">
         <xsl:variable name="counter" select="java:java.util.Vector.new()"/>
         <xsl:variable name="temp1" select="java:add($counter,'1')"/>
         <xsl:variable name="temp2" select="java:add($counter,'2')"/>
         <xsl:variable name="temp3" select="java:add($counter,'3')"/>
         <xsl:value-of select="java:size($counter)"/>
         <xsl:value-of select="java:toString($counter)"/>
         </xsl:template>
    </xsl:stylesheet>
    With jdk 1.5 it creates following output:
    3
    [1, 2, 3]
    With jdk 1.6 I get:
    0
    So I can access the object in jdk 1.6 but adding doesn't work.
    Anybody has an idea what could be wrong or how to fix this?

    thanx this is the solution. With this construct
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java">
         <xsl:output method="html" indent="yes" encoding="iso-8859-1"/>
         <xsl:template match="/">
         <xsl:variable name="counter" select="java:java.util.Vector.new()"/>
         <xsl:variable name="temp1" select="java:add($counter,'1')"/>
         <xsl:variable name="temp2" select="java:add($counter,'2')"/>
         <xsl:variable name="temp3" select="java:add($counter,'3')"/>
         <xsl:variable name="temp4" select="$temp3"/>
         <xsl:value-of select="java:size($counter)"/>
         <xsl:value-of select="java:toString($counter)"/>
         </xsl:template>
    </xsl:stylesheet>
    at least the '3' is added to the vector.

  • Version compatibility  of 10G Application Server 10.1.2.0.2  with  JDK 1.5.

    hi buddies,
    I want to know that whether
    10G Application Server 10.1.2.0.2 with JDK 1.5. is Version compatibility
    pls do send ur replies if known to you.

    Hi ,
    As far as I know AS 10.1.2.0.2 is Not certified with JDK 1.5.
    Please see below some links where you can double-check this
    1. OC4J with JDK 1.5 JSP compilation error
    2. http://docs.huihoo.com/oracle/docs/B14099_19/web.1012/b14011/chap1.htm
    "Only the JDK 1.3.1 and JDK 1.4 compilers are supported and certified by OC4J. It is possible to specify an alternative compiler by adding a <java-compiler> element to the server.xml file, and this might provide a workaround for the "classes not in packages" issue, but no other compilers are certified or supported by Oracle for use with OC4J."
    3. "Certified JDKs" from
    http://www.oracle.com/technology/software/products/ias/files/as_certification_r2_101202.html
    BR,
    Mihai

  • 10G Application Server 10.1.2.0.2 with JDK 1.5.0_16 is Version compatible

    hi buddies,
    I want to know that whether
    10G Application Server 10.1.2.0.2 with JDK 1.5.0_16 is Version compatible
    pls do send ur replies if known to you.

    Hi ,
    As far as I know AS 10.1.2.0.2 is Not certified with JDK 1.5.
    Please see below some links where you can double-check this
    1. OC4J with JDK 1.5 JSP compilation error
    2. http://docs.huihoo.com/oracle/docs/B14099_19/web.1012/b14011/chap1.htm
    "Only the JDK 1.3.1 and JDK 1.4 compilers are supported and certified by OC4J. It is possible to specify an alternative compiler by adding a <java-compiler> element to the server.xml file, and this might provide a workaround for the "classes not in packages" issue, but no other compilers are certified or supported by Oracle for use with OC4J."
    3. "Certified JDKs" from
    http://www.oracle.com/technology/software/products/ias/files/as_certification_r2_101202.html
    BR,
    Mihai

  • Java 6u24 won't launch signed JNLP app with classes compiled with JDK 1.4.2

    Anyone else having a problem launching a JNLP app compiled with Java 1.4 using Java 6u24 on the client? Anyone have a Java 1.4-compiled app that does launch with Java 6u24?
    I am, and I have isolated the problem to some change in 6u24's java web start launching logic. The splash screen appears and then javaws just quits with no error. Trace shows it is not getting past checking of the first .jar. My JNLP app, fully signed with CA-issued certificate, when compiled with Java 1.4.2 will not launch on JRE 6u24 (or 6u25-b03). The same exact app launches perfectly fine when it is compiled with JDK 1.5 or 1.6. It is not a signing problem, though it is related to certificate checking logic or a concurrency flaw in javaws' AppPolicy and TrustDecider classes. It is not a host server or network problem as those have been varied with same results. It is not a specific .jar problem as I have varied what is the first .jar with same results. I have eliminated all other variables to find the only difference is what Java version the app is compiled with. Well, all but one other variable - I have not tried with apps other than mine.
    My app is compiled with JDK 1.4.2 so I can still support older platforms. That requirement is going away soon but this is still a regression from 6u23 that is causing a big problem for at least this developer.

    You can try to use the version of the jarsigner JDK 1.5 or later.
    Has changed the management of files in META-INF.
    So compile with 1.4 but sign with 1.5 or later

  • Warning 'Calculating result as....' was not executed

    Hi all,
    At the time of executing a report, after giving the inputs for variables I am getting an warning messager: Warning 'Calculating result as....' was not executed'.
    Kindly advise.
    Thank you,
    Praveen

    Hi
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/9794b990-0201-0010-2cb4-962bff1f0d19
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a0ceb827-e6c1-2b10-4b94-de298fccade3
    http://help.sap.com/saphelp_nw04/helpdata/en/0d/af12403dbedd5fe10000000a155106/frameset.htm
    www.scribd.com/doc/6412427/How-Tobuild-BEx-Analyzer-Workbooks-for-Planning-With-Excel-Design-Objects

  • Displaying results with a decimal place of two. Forcing decimal place.

    Hi there,
    Im writing a simple calculation device.
    You input one digit and press one of two buttons to multiply it by a certain number and then the result is displayed. The result is displyed hiding the result of the button you didn't press and visa versa.
    I am having a problem displaying the result with a constant two decimal place.
    I am using strings and thus don't know how to do this.
    Here is my code:
    import flash.events.MouseEvent;
    //restrict the input textfield to only numbers
    txtinput.restrict = "0-9";
    //restrict the input textfield to only two characters
    txtinput.maxChars = 6;
    // event listeners
    btnW.addEventListener(MouseEvent.CLICK, WHandler);
    btnC.addEventListener(MouseEvent.CLICK, CHandler);
    btnW.addEventListener(MouseEvent.CLICK, hideC);
    btnC.addEventListener(MouseEvent.CLICK, hideW);
    //functions
    function WHandler (e:MouseEvent):void
              //white calculation
              var answerW:Number = Number(txtinput.text) * Number(0.90);
              txtWResult.text = answerW.toString();
    function CHandler (e:MouseEvent):void
              //colour calculation
              var answerC:Number = Number(txtinput.text) * Number(0.99);
              txtCResult.text = answerC.toString();
    function hideC (e:MouseEvent):void
              //Hide colour result
              txtCResult.visible = false;
              txtWResult.visible = true;
    function hideW (e:MouseEvent):void
              //Hide white result
              txtWResult.visible = false;
              txtCResult.visible = true;
    After having a look online I have found these two resources:
    http://helpx.adobe.com/flash/kb/rounding-specific-decimal-places-flash.html
    and
    http://stackoverflow.com/questions/11469321/decimals-to-one-decimal-place-in-as3
    But I am confused when combining these techniques with strings.
    Any help would be greatly appreciated,
    Thanks in advance
    Mr B

    Use the toFixed() method of the Number class instead of the toString() method.  The result of it is a String with the number of decimal places you specify.
              var answerW:Number = Number(txtinput.text) * Number(0.90);
              txtWResult.text = answerW.toFixed(2);
              var answerC:Number = Number(txtinput.text) * Number(0.99);
              txtCResult.text = answerC.toFixed(2);

  • Custom Calculation terminated with Essbase error 1200685 in POV

    I'm trying to improve the efficiency of an ASO calculation script by limiting the scope of the calculation using a filter within the POV.
    When I do this, I get an error that says MDX error: A symmetric set expression is expected. Custom Calculation terminated with Essbase error 1200685 in POV.
    Using a similar filter in an mdx query I can see that I should be updating approximately 5000 data points. That query returns data in less than a minute. If I remove the filter, the calc will run over 16 hours and not complete (I've killed it at that point). [FI - Begining Balance Calc] is a calculated member, which is dependent on other calculations. I'm thinking that the calculation is churning for all of the potential member combinations regardless of sparseness of the data.
    Error 1200685 is not documented in the Essbase Error Message guide. Any ideas on this anyone?
    calc_1.txt contains:
    [FI - Beginning Balance Stored] := [FI - Beginning Balance Calc];
    execute calculation on database REVFCTA.REVFCTA with
    local script_file "E:\Oracle\Middleware\user_projects\epmsystem1\EssbaseServer\essbaseserver1\app\REVFCTA\REVFCTA\calc_1.txt"
    POV "FILTER(CROSSJOIN(
    CROSSJOIN(
    CROSSJOIN(
    CROSSJOIN(
    CROSSJOIN(
    CROSSJOIN({[Y.2011]},{[SEG.S0001]}),
    {[FORECAST]}),
    [ASSET TYPE].Levels(0).members),
    [FUND_INVESTOR].levels(0).members),
    [OZ_FUND].levels(0).members),
    {[PER.2]}), NOT ISEMPTY([FI - Beginning Balance]))"
    SourceRegion "({[FI - Beginning Balance Calc]})";
    This is the mdx query:
    SELECT
    {[FI - Beginning Balance Calc]} ON COLUMNS,
    FILTER(CROSSJOIN(CROSSJOIN([FUND_INVESTOR].Levels(0).members,
    [ASSET TYPE].LEVELS(0).MEMBERS),
    OZ_FUND.[OZ_FUND].LEVELS(0).MEMBERS), NOT ISEMPTY([FI - Beginning Balance]))
    ON ROWS
    FROM [REVFCTA.REVFCTA]
    WHERE ([Y.2011],[PER.2],[SEG.S0001],[FORECAST])

    I don't think it's so much that it no longer applies in current versions as that people don't understand that it only ever applied if you had multiple conditions testing more than one dense member.
    I still think that...
    FIX("Dense1", "Sparse1")
         Do something to Dense1
    ENDFIX
    FIX"Dense2", "Sparse1")
         Do something to Dense2
    ENDFIX
    ...is often going to be slower than...
    FIX("Sparse1")
         IF "Dense1"
              Do something to Dense1
         IF "Dense2"
              Do something to Dense2
    ENDFIX
    ...unless the subset of blocks is small enough that caching (Essbase or OS) results in the "Sparse1" blocks not having to be read from / written back to disk twice.

  • 'Calculating result as...' was not executed ???

    Hi,
    can anyone explain me the warning message that i received.
    I have a query, and in its definition, three characteristcs are added to the "rows" (Region, District, StoreId) and the option "Display as hierarchy" is selected, expanding to "Region". Region has 4 values (north, south, east, west) So when query is run, it displays 4 nodes.
    When i execute the query, this warning message shows up "<b>'Calculating result as...' was not executed</b> ". It calculates the results correctly for the first three nodes and fails to calculate it for the last node. The result displayed for the last node is wrong.
    Could you please share your comments on this.
    Thanks
    Gova
    This is the detailed message.
    <b>Diagnosis</b>
    The function 'Calcualte Results As ...' could not be applied everywhere.
    The recalculation of a result cell always takes place based on the amount of detail cells that are subordinate to this cell, that is the detail of this drilldown. For this reason it is not possible to recalculate results in hierarchical lists, that is calculate of a results cell is not performed if a row or column with expansion symbol is subordinate to it. This is because otherwise this newly calculated results would have to change every time a node subordinate to it was expanded. This is not supported for technical reasons and would also confuse the user.
    Note however, that calculate as "Suppress Results" is always executed
    because the above exception does not apply in this case.
    Any answers please. I am known to be generous in assigning points

    Did you ever receive any further information on this topic?  I am receiving the exact error you received and I know this was possible in BW 3.2.  My customers have been using this report now for months.  I would like to know how to activate this same reporting in BW 3.5 
    Thanks so much! 
    Kristie

  • HAT 1.1 and HPROF not working with JDK 1.5

    I'm using JDK 1.5.0_05, and I run HPROF with these args passed to the JVM:
    -Xrunhprof:heap=sites,depth=8,monitor=n,thread=n,doe=y,format=b
    When I try to read the binary file output I get the following error:
    C:\dev\142\sfdc>java -jar c:\HAT\bin\hat.jar c:\dev\142\sfdc\java.hprof
    Started HTTP server on port 7000
    Reading from c:\dev\142\sfdc\java.hprof...
    Dump file created Thu Feb 09 17:10:38 PST 2006
    Snapshot read, resolving...
    Resolving 0 objects...
    WARNING: hprof file does not include java.lang.Class!
    Exception in thread "main" java.lang.NullPointerException
    at hat.model.JavaClass.resolve(JavaClass.java:68)
    at hat.model.Snapshot.addFakeClass(Snapshot.java:73)
    at hat.model.Snapshot.resolve(Snapshot.java:111)
    at hat.Main.main(Main.java:158)
    I've also tried using JDK 1.5.0_04 and JDK 1.5.0_01. I've reduced the depth param to depth=4. Nothing gets rid of that error.
    Can HAT work with JDK 1.5?

    Ok, I finally managed to solve this problem. What was happening was that IPv6 was installed on this computer, and as a result Java was trying to do a DNS lookup using a IPv6 socket and failing. With the help of TracePlus Winsock, I discovered that internall Java's InetAddress.getByName does this:
    WSAStartup
    socket(INET6)
    getaddrinfo
    WSACleanup
    Two solutions are possible - either set the system preference java.net.preferIPv4Stack to true, or uninstall the IPv6 stack. Since I couldn't find a way to set the system preference in a persistent manner (apart from passing in an argument on the java command line), I uninstalled the IPv6 stack.
    Hope this helps someone else.
    Peter

Maybe you are looking for