Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6231847
Votes 1
Synopsis crash: java.lang.NullPointerException at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1352)
Category java:compiler
Reported Against
Release Fixed mustang(b65)
State 10-Fix Delivered, Verified, bug
Priority: 2-High
Related Bugs 6244020 , 6324907
Submit Date 22-FEB-2005
Description
FULL PRODUCT VERSION :
$ java -version
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
 customer  Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
Invoking compiler causes crash.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac crash.java

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
program compile
ACTUAL -
compiler crashed

ERROR MESSAGES/STACK TRACES THAT OCCUR :
$ javac crash.java
An exception has occurred in the compiler (1.5.0_01). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)
 after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
java.lang.NullPointerException
        at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:1352)
        at com.sun.tools.javac.tree.Tree$NewClass.accept(Tree.java:845)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:295)
        at com.sun.tools.javac.comp.Attr.visitAssign(Attr.java:1426)
        at com.sun.tools.javac.tree.Tree$Assign.accept(Tree.java:887)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:302)
        at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:896)
        at com.sun.tools.javac.tree.Tree$Exec.accept(Tree.java:734)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
        at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:331)
        at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:599)
        at com.sun.tools.javac.tree.Tree$Block.accept(Tree.java:540)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
        at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:532)
        at com.sun.tools.javac.tree.Tree$MethodDef.accept(Tree.java:482)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:280)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:315)
        at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2473)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2406)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2355)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:444)
        at com.sun.tools.javac.main.Main.compile(Main.java:592)
        at com.sun.tools.javac.main.Main.compile(Main.java:544)
        at com.sun.tools.javac.Main.compile(Main.java:67)
        at com.sun.tools.javac.Main.main(Main.java:52)

Lyle   xxxxx@xxxxx   ~/java
$

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.lang.*;
import java.io.*;

import java.awt.event.*;

public class crash extends JFrame {

    public crash(String file) {
        super(file);
    }

    public static void main(String[] args) {

    }
}

class PriceGraph extends JLabel{
//class PriceGraph extends JLabel
    ArrayList <OHLC> ohlc = new ArrayList<OHLC>();
    Comparator <OHLC>findMaxHigh = null;
	Comparator <OHLC>findMinLow = null;

    PriceGraph (int pH, String file){
        super();

        findMinLow = new<OHLC> Comparator(){  // this is the line that causes the crash
                         public int compare (Object x1, Object x2){
                             return 1;
                         }
                     };

        findMaxHigh = new Comparator<OHLC>(){
                          public int compare (OHLC x1, OHLC x2){
                              double high1 = x1.high;
                              double high2 = x2.high;
                              int value =  high1 < high2 ? -1 : (high1 == high2 ? 0 : 1);
                              return value;
                          }
                      };

    }
    public void paintComponent (Graphics gc){
    }

}

class OHLC {
    int date;
    double open, high, low, close;
    OHLC(String dt, double o, double h, double l, double c){
        open = o; high = h; low  = l; close = c;
        String str[] = dt.split("/");
        date = Integer.decode(str[2] + str[0] + str[1]);
    }
    OHLC(String line){
        int delta;
        String fields[] = line.split(",");
        delta = fields.length == 6 ? 1 : 0;
        String mmddyyyy[] = fields[0].split("/");
        date  = Integer.decode(mmddyyyy[2] + mmddyyyy[0] + mmddyyyy[1]);
        open  = Double.parseDouble (fields[1 + delta]);
        high  = Double.parseDouble (fields[2 + delta]);
        low   = Double.parseDouble (fields[3 + delta]);
        close = Double.parseDouble (fields[4 + delta]);
    }
};


---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Avoid the syntax error that causes the crash.
  xxxxx@xxxxx   2005-2-22 21:29:13 GMT
Work Around
N/A
Evaluation
Here is a smaller example:

interface I {}

class A {
    Object o = new <Object> I() {};
}

We should fix this in Mustang and backport the fix to 5.0.

  xxxxx@xxxxx   2005-03-17 07:59:44 GMT
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang