Community
Participate
Working Groups
Build ID: I20070323-1616 Steps To Reproduce: I am unsure how to reproduce this bug. I had been running eclipse 3.2 with this workspace with no issues. I ran Eclipse 3.3 m6 against the same workspace and upon launch I noticed I had this strange error in my task list. Doing a clean all did not help. Note my target compiler is Java 1.5.11. More information: Severity and Description Path Resource Location Creation Time Id Internal compiler error java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.flow.ConditionalFlowInfo.unconditionalInits(ConditionalFlowInfo.java:207) at org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo.addInitializationsFrom(UnconditionalFlowInfo.java:93) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.internalAnalyseCode(TypeDeclaration.java:655) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode(TypeDeclaration.java:253) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.analyseCode(CompilationUnitDeclaration.java:107) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:621) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:391) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:356) at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:173) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:293) at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:59) at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:254) at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:172) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:163) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:248) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:251) at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:307) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:339) at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:137) at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58) core/src/com/bsideinc/utils DateUtils.java line 0 1174925086542 65610 ****************** from .metadata/.log: !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui". !STACK 0 java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.flow.ConditionalFlowInfo.unconditionalInits(ConditionalFlowInfo.java:207) at org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo.addInitializationsFrom(UnconditionalFlowInfo.java:93) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.internalAnalyseCode(TypeDeclaration.java:655) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode(TypeDeclaration.java:253) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.analyseCode(CompilationUnitDeclaration.java:107) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:852) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:517) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:867) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:651) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:606) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:601) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:514) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:502) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:155) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:140) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Could you please try to simplify core/src/com/bsideinc/utils/DateUtils.java and see whether this gets rid of the error or else share its contents with us?
Strange... I was not able to work using 3.3m6 so I switched to 3.2.. worked until now.. quit... then started with 33m6 and now it is compiling just fine. I will continue to use 33m6 and see if it comes back up. Here is the source for the file just in case it may be useful: public class DateUtils { private static Map<String, String> s_timezoneMappings = new HashMap<String, String>(); static { s_timezoneMappings.put("ET", "America/New_York"); s_timezoneMappings.put("EST", "America/New_York"); s_timezoneMappings.put("EDT", "America/New_York"); s_timezoneMappings.put("America/New_York", "America/New_York"); s_timezoneMappings.put("CT", "America/Chicago"); s_timezoneMappings.put("CST", "America/Chicago"); s_timezoneMappings.put("CDT", "America/Chicago"); s_timezoneMappings.put("America/Chicago", "America/Chicago"); s_timezoneMappings.put("MT", "America/Denver"); s_timezoneMappings.put("MST", "America/Denver"); s_timezoneMappings.put("MDT", "America/Denver"); s_timezoneMappings.put("America/Denver", "America/Denver"); s_timezoneMappings.put("PT", "America/Los_Angeles"); s_timezoneMappings.put("PST", "America/Los_Angeles"); s_timezoneMappings.put("PDT", "America/Los_Angeles"); s_timezoneMappings.put("America/Los_Angeles", "America/Los_Angeles"); s_timezoneMappings.put("AT", "America/Anchorage"); s_timezoneMappings.put("AST", "America/Anchorage"); s_timezoneMappings.put("ADT", "America/Anchorage"); s_timezoneMappings.put("America/Anchorage", "America/Anchorage"); s_timezoneMappings.put("HT", "Pacific/Honolulu"); s_timezoneMappings.put("HST", "Pacific/Honolulu"); s_timezoneMappings.put("HDT", "Pacific/Honolulu"); s_timezoneMappings.put("Pacific/Honolulu", "Pacific/Honolulu"); } /** * Converts various old timezone name formats into the new format (ie, ET -> America/New_York). * @param timezone * @return * @throws NullPointerException if timezone is null */ public static TimeZone getCanonicalTimezone(String timezone) { return TimeZone.getTimeZone(s_timezoneMappings.get(timezone)); } /** * Returns a new {@link Calendar} instance as a copy of the the given {@link Calendar} in the provided * {@link TimeZone} * @throws NullPointerException if any of the parameters are null */ public static Calendar toTimeZone(Calendar c, TimeZone tz) { Calendar cnew = Calendar.getInstance(tz); cnew.setTimeInMillis(c.getTimeInMillis()); return cnew; } /** * Calculates the number of days that the two dates differ by (c2 - c1). For example: * <table> * <tr><th>c1</th><th>c2</th><th>day diff</th></tr> * <tr><td>2006-12-20 08:00</td><td>2006-12-20 23:00</td><td>0</td></tr> * <tr><td>2006-12-20 08:00</td><td>2006-12-21 07:00</td><td>1</td></tr> * <tr><td>2006-12-20 08:00</td><td>2006-12-21 17:00</td><td>1</td></tr> * <tr><td>2006-04-01 08:00</td><td>2006-04-02 08:00 (after DST change)</td><td>1</td></tr> * </table> * @param c1 * @param c2 * @return * @throws IllegalArgumentException if the Calendars are in different timezones * @throws NullPointerException if any of the parameters are null */ public static int dayDiff(Calendar c1, Calendar c2) { // if the two dates are in different timezones, we don't know which one to do the comparison in if (!c1.getTimeZone().equals(c2.getTimeZone())) throw new IllegalArgumentException("Can't compute day diff when calendars have different timezones"); // normalize both dates to 8am on their respective days. Calendar work1 = (Calendar) c1.clone(); work1.set(Calendar.HOUR_OF_DAY, 8); work1.set(Calendar.MINUTE, 0); work1.set(Calendar.SECOND, 0); work1.set(Calendar.MILLISECOND, 0); Calendar work2 = (Calendar) c2.clone(); work2.set(Calendar.HOUR_OF_DAY, 8); work2.set(Calendar.MINUTE, 0); work2.set(Calendar.SECOND, 0); work2.set(Calendar.MILLISECOND, 0); // compute the diff in days via milliseconds. then round to the nearest integer as that will take care of // the 23 hr (spring) and 25 hr (fall) days attributed to daylight savings time double rawDiff = (work2.getTimeInMillis() - work1.getTimeInMillis()) / (24.0 * 60 * 60 * 1000); return (int) Math.round(rawDiff); } }
Thanks for the elements. Having a closer look at the stack trace and at the code, I'm a bit puzzled. From TypeDeclaration#654 I take that outerInfo is an UnconditionalFlowInfo or else we should get a CCE (a careful look at the code leaves little doubt if any, but the explicit use of an UnconditionalFlowInfo type clears it anyway). Hence the call to unconditionalInits at UnconditionalFlowInfo#93 should select UnconditionalFlowInfo#unconditionalInits at runtime, instead of the ConditionalFlowInfo#unconditionalInits which raises the NPE. Kent, could you please have a look and let me know what you think? (Most probable is that I miss something. Or else one of the generated code or the jvm would be wrong - but I can't quite see how that could be without causing many more errors.)
The only way to initialize either field (initsWhenTrue or initsWhenFalse) to null is thru the default constructor for ConditionalFlowInfo, but no sender appears to pass null. Only 2 implementations of unconditionalInits() exist, this one with the NPE on the first line (207) : public UnconditionalFlowInfo unconditionalInits() { return initsWhenTrue.unconditionalInits(). mergedWith(initsWhenFalse.unconditionalInits()); } and this one in UnconditionalFlowInfo : public UnconditionalFlowInfo unconditionalInits() { return this; } So if unconditionalInits() doesn't answer null, it would have to be one of the calls to constructor for ConditionalFlowInfo, but there are only 2. The first is in ConditionalFlowInfo : public FlowInfo copy() { // no implementation of copy answers null return new ConditionalFlowInfo(initsWhenTrue.copy(), initsWhenFalse.copy()); } and the second is in FlowInfo : public static FlowInfo conditional(FlowInfo initsWhenTrue, FlowInfo initsWhenFalse) { return new ConditionalFlowInfo(initsWhenTrue, initsWhenFalse); } This one is called from 5 analyseCode() methods but none of those methods pass null as an argument. I do not see how a NPE could occur at line 207
So we both agree, thanks for investigating. Ryan, I will close this bug as WORKSFORME, since we have no reproduceable test case (so far) and neither Kent nor I see how the stack trace you attached could happen without something going really weird underneath. Please reopen if you get those errors again, especially if you can nail down a test case.
Verified for 3.3M7 using I20070427-0010