scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Cannot create new Scala object #2380

Closed scabug closed 13 years ago

scabug commented 14 years ago

Steps to reproduce: Create new scala project, create a package with some name, right click on the package and choose "new object". Using Eclipse Galileo, MacOS X. Scala Eclipse plugin 2.7.6.final.

eclipse.buildId=I20090611-1540 java.version=1.5.0_19 java.vendor=Apple Inc. BootLoader constants: OS=macosx, ARCH=x86, WS=cocoa, NL=en_US Framework arguments: -product org.eclipse.epp.package.jee.product -keyring /Users/johan/.eclipse_keyring -showlocation Command-line arguments: -os macosx -ws cocoa -arch x86 -product org.eclipse.epp.package.jee.product -keyring /Users/johan/.eclipse_keyring -showlocation

java.lang.NullPointerException at scala.tools.eclipse.wizards.NewResourceWizard$$class.name(NewResourceWizard.scala:129) at scala.tools.eclipse.wizards.NewObjectWizard.name(NewObjectWizard.scala:9) at scala.tools.eclipse.wizards.NewResourceWizard$$class.performFinish(NewResourceWizard.scala:142) at scala.tools.eclipse.wizards.NewObjectWizard.performFinish(NewObjectWizard.scala:9) at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:752) at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373) at org.eclipse.jface.dialogs.Dialog$$2.widgetSelected(Dialog.java:624) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3542) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1247) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1270) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1255) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1076) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3440) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3099) at org.eclipse.jface.window.Window.runEventLoop(Window.java:825) at org.eclipse.jface.window.Window.open(Window.java:801) at org.eclipse.ui.internal.actions.NewWizardShortcutAction.run(NewWizardShortcutAction.java:135) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3542) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1247) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1270) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1255) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1076) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3440) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3099) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369) at org.eclipse.ui.internal.Workbench.access$$4(Workbench.java:2221) at org.eclipse.ui.internal.Workbench$$5.run(Workbench.java:500) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514) at org.eclipse.equinox.launcher.Main.run(Main.java:1311)

scabug commented 14 years ago

Imported From: https://issues.scala-lang.org/browse/SI-2380?orig=1 Reporter: Johan Nystrom (jtnystrom)

scabug commented 14 years ago

@milessabin said: That stack trace looks like a side-effect of an earlier failure when the New Scala object dialog was first opened. Are there any relevant looking entries showing up in the Eclipse Error Log view?

Independently of that, could you run through the troubleshooting section [http://www.scala-lang.org/node/94 here] and let me know how you get on.

scabug commented 14 years ago

spybreak said: I'm having the same problem, I cannot create any object, trait or whatever. The wizard is also empty.

The !NullPointerException comes as the second message, the first message is:

java.lang.NoSuchMethodError: java.lang.String.isEmpty()Z
at scala.tools.eclipse.wizards.NewResourceWizard$$Page.createControl(NewResourceWizard.scala:83)
at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:170)
at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:675)
at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:549)
...

It seems the Scala plugin uses Java 1.6 methods, while Eclipse on Mac OS X runs with Java 1.5.

scabug commented 14 years ago

thsoft said: Yes, String.isEmpty() is called, which is Java 6-only, and since I use the 32-bit Cocoa version, I must use Java 5. So either strip Java 6-only API usage or don't state at the requirements the Java 5 is supported...

scabug commented 14 years ago

@milessabin said: Tentatively fixed in r18760 and r18761.

This turns out to be a surprisingly tricky issue.

j.l.String.isEmpty is a Java 1.6 method. However, when viewed from Scala, it's present even when compiled/run against 1.5 because isEmpty is pimped onto String via RichString's implementation of Seq. The generated bytecode is different depending on whether source using isEmpty is compiled against 1.5 or 1.6 and, as you've discovered, the 1.6 bytecode fails when run on a 1.5 VM.

The default builds provided by EPFL are compiled against 1.6, and there's no time to change this for 2.7.7. I'm not even sure that this would be desirable given that Sun is EOL'ing 1.5 on the 30th of October (at least for non-paying customers).

So I've attempted to fixed this by replacing the problematic uses of isEmpty with uses of length == 0. I don't consider this satisfactory, however, and you need to be aware that simply recompiling against 1.5 isn't sufficient to catch all possible uses of this method (or other similar cases). Can the affected parties please test tonight's nightly tomorrow (24th Sept) and report back on whether this particular issue is fixed.

Longer term we need a tool which is able to audit generated bytecode for compliance with specified JDK baselines.

scabug commented 14 years ago

spybreak said: The nightly build site only shows the 2.8.0 plugin.

We are also using Java 1.6 to run our projects, however 1.6 is 64 Bit on Mac OS X, and Eclipse runs in 32 Bit, so Eclipse itself can only use 1.5.

In Eclipse, you can change the compiler settings on a per-project basis to create source- and byte-code in 1.5 format (project Properties - Java Compiler).

scabug commented 14 years ago

@milessabin said: My mistake ... the nightlies are indeed trunk-only.

There should be a 2.7.7 RC imminently: please test that ASAP.

scabug commented 14 years ago

spybreak said: Will the 2.7.7RC appear on the nightly site? Neither update site shows anything new so far.

scabug commented 14 years ago

@milessabin said: There'll be an announcement on the lists and on scala-lang.org.

scabug commented 14 years ago

spybreak said: Alright thanks. By the way I just downloaded the 64 Bit Eclipse nightly and with that the 2.7.6 final seems to work fine (except a small exception when first opening the just created !HelloWorld.scala).