JDK-7119180 : Compiling a program under NetBeans 7.0.1
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2011-12-08
  • Updated: 2012-03-20
  • Resolved: 2011-12-08
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
C:\>java -version
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode, sharing)

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

A DESCRIPTION OF THE PROBLEM :
Compiling program with switches in it.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the program.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Clean compile.
ACTUAL -
An exception has occurred in the compiler (1.7.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.Lower.visitStringSwitch(Lower.java:3456)
	at com.sun.tools.javac.comp.Lower.visitSwitch(Lower.java:3357)
	at com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:959)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.Lower.translate(Lower.java:2160)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
	at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:160)
	at com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:3311)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:781)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.Lower.translate(Lower.java:2160)
	at com.sun.tools.javac.tree.TreeTranslator.visitTry(TreeTranslator.java:216)
	at com.sun.tools.javac.comp.Lower.visitTry(Lower.java:3612)
	at com.sun.tools.javac.tree.JCTree$JCTry.accept(JCTree.java:1044)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.Lower.translate(Lower.java:2160)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
	at com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:160)
	at com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:3311)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:781)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.Lower.translate(Lower.java:2160)
	at com.sun.tools.javac.tree.TreeTranslator.visitMethodDef(TreeTranslator.java:144)
	at com.sun.tools.javac.comp.Lower.visitMethodDefInternal(Lower.java:2619)
	at com.sun.tools.javac.comp.Lower.visitMethodDef(Lower.java:2538)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:669)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.Lower.translate(Lower.java:2160)
	at com.sun.tools.javac.comp.Lower.visitClassDef(Lower.java:2283)
	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:591)
	at com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
	at com.sun.tools.javac.comp.Lower.translate(Lower.java:2160)
	at com.sun.tools.javac.comp.Lower.translate(Lower.java:2180)
	at com.sun.tools.javac.comp.Lower.translateTopLevelClass(Lower.java:3650)
	at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1393)
	at com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1271)
	at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:870)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:829)
	at com.sun.tools.javac.main.Main.compile(Main.java:417)
	at com.sun.tools.javac.main.Main.compile(Main.java:331)
	at com.sun.tools.javac.main.Main.compile(Main.java:322)
	at com.sun.tools.javac.Main.compile(Main.java:76)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
	at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1134)
	at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:912)
	at org.netbeans.modules.java.source.ant.JavacTask.execute(JavacTask.java:144)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
	at sun.reflect.GeneratedMethodAccessor337.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
	at sun.reflect.GeneratedMethodAccessor337.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
	at sun.reflect.GeneratedMethodAccessor337.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.Target.execute(Target.java:390)
	at org.apache.tools.ant.Target.performTasks(Target.java:411)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
	at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:284)
	at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539)
	at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package org.delta.mtv.db;

import java.sql.SQLException;
import java.util.HashMap;
import org.apache.log4j.Logger;

/**
 *
 * @author ca31319
 */
public class ResultSetMetaData {

    static Logger log = Logger.getLogger(ResultSetMetaData.class);
    private java.sql.ResultSetMetaData theMeta;
    private HashMap<String, Integer> columnMap;

    /**
     * constr
     * @param resultSet
     */
    public ResultSetMetaData(java.sql.ResultSetMetaData resultSetMeta) {
        theMeta = resultSetMeta;
        columnMap = new HashMap();
        try {
            int size = resultSetMeta.getColumnCount();
            for (int i = 0; i < size; i++) {
                columnMap.put(resultSetMeta.getColumnName(i), i);
            }
        } catch (SQLException ex) {
            log.error(ex);
        }
    }

    boolean isString(String cName) {
        Integer i = columnMap.get(cName);
        try {
            String tn = theMeta.getColumnTypeName(i).toLowerCase();
            switch (tn) {
                case ("varchar"):
                    return true;
                case ("char"):
                    return true;
                case ("nchar"):
                    return true;
                default:
                    return false;
            }
        } catch (SQLException ex) {
            log.error(ex);
        }
        return false;
    }

    /**
     * check type can be converted into an integer
     * @param cName
     * @return
     */
    boolean isInteger(String cName) {
        Integer i = columnMap.get(cName);
        try {
            String tn = theMeta.getColumnTypeName(i).toLowerCase();
            switch (tn) {
                case ("int"):
                    return true;
                case ("smallint"):
                    return true;
                case ("number"):
                    return true;
                case ("integer"):
                    return true;
                default:
                    return false;
            }
        } catch (SQLException ex) {
            log.error(ex);
        }
        return false;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        return sb.toString();
    }
}

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

CUSTOMER SUBMITTED WORKAROUND :
if () {} else ...