awips2 icon indicating copy to clipboard operation
awips2 copied to clipboard

The constructor MapConfiguration(HashMap<Object,Object>) is undefined

Open mjames-upc opened this issue 6 years ago • 1 comments

Spring initialization took: 3597 ms
No component specified, defaulting to 'thinclient'
Time to restore thin client caches: 1323ms
EVENTA 2018-08-28 16:25:37 com.raytheon.uf.viz.core.localization.LocalizationManager: DEFAULT: CAVE - Localizing as site OAX
awips_site_list.xml
!SESSION 2018-08-28 10:25:28.922 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_181
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -data @user.home/caveData -user @user.home/caveData -clean -consoleLog

!ENTRY org.eclipse.equinox.event 4 0 2018-08-28 10:25:48.792
!MESSAGE Exception while dispatching event org.osgi.service.event.Event [topic=org/eclipse/e4/ui/model/ui/ElementContainer/selectedElement/SET] {ChangedElement=org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl@7c9c7e7d (elementId: org.eclipse.e4.primaryDataStack, tags: [org.eclipse.e4.primaryDataStack, EditorStack], contributorURI: null) (widget: CTabFolder {}, renderer: com.raytheon.uf.viz.personalities.cave.presentation.VizStackRenderer@4679554d, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null), Widget=CTabFolder {}, org.eclipse.e4.data={ChangedElement=org.eclipse.e4.ui.model.application.ui.basic.impl.PartStackImpl@7c9c7e7d (elementId: org.eclipse.e4.primaryDataStack, tags: [org.eclipse.e4.primaryDataStack, EditorStack], contributorURI: null) (widget: CTabFolder {}, renderer: com.raytheon.uf.viz.personalities.cave.presentation.VizStackRenderer@4679554d, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null), AttName=selectedElement, EventType=SET, Widget=CTabFolder {}, NewValue=org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@4446e1d9 (elementId: org.eclipse.e4.ui.compatibility.editor, tags: [Editor, com.raytheon.viz.ui.glmap.GLMapEditor, removeOnHide], contributorURI: null) (widget: ContributedPartRenderer$2 {}, renderer: org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer@37d50217, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor, object: null, context: PartImpl (org.eclipse.e4.ui.compatibility.editor) Context, variables: [], label: null, iconURI: null, tooltip: null, dirty: false, closeable: true, description: null)}, AttName=selectedElement, NewValue=org.eclipse.e4.ui.model.application.ui.basic.impl.PartImpl@4446e1d9 (elementId: org.eclipse.e4.ui.compatibility.editor, tags: [Editor, com.raytheon.viz.ui.glmap.GLMapEditor, removeOnHide], contributorURI: null) (widget: ContributedPartRenderer$2 {}, renderer: org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer@37d50217, toBeRendered: true, onTop: false, visible: true, containerData: null, accessibilityPhrase: null) (contributionURI: bundleclass://org.eclipse.ui.workbench/org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor, object: null, context: PartImpl (org.eclipse.e4.ui.compatibility.editor) Context, variables: [], label: null, iconURI: null, tooltip: null, dirty: false, closeable: true, description: null), EventType=SET} to handler org.eclipse.e4.ui.services.internal.events.UIEventHandler@65cb50dc
!STACK 0
java.lang.Error: Unresolved compilation problem:
        The constructor MapConfiguration(HashMap<Object,Object>) is undefined

        at com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore.getDefaultConfig(HierarchicalPreferenceStore.java:240)
        at com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore.getStringArray(HierarchicalPreferenceStore.java:652)
        at com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore.getStringArray(HierarchicalPreferenceStore.java:630)
        at com.raytheon.viz.ui.input.preferences.MousePreferenceManager.init(MousePreferenceManager.java:116)
        at com.raytheon.viz.ui.input.preferences.MousePreferenceManager.<init>(MousePreferenceManager.java:107)
        at com.raytheon.viz.ui.input.preferences.MousePreferenceManager.getInstance(MousePreferenceManager.java:83)
        at com.raytheon.viz.ui.panes.VizDisplayPane.<init>(VizDisplayPane.java:168)
        at com.raytheon.viz.ui.panes.PaneManager.createNewPane(PaneManager.java:565)
        at com.raytheon.viz.ui.panes.PaneManager.addPane(PaneManager.java:524)
        at com.raytheon.viz.ui.panes.PaneManager.addPane(PaneManager.java:579)
        at com.raytheon.viz.ui.editor.AbstractEditor.addPane(AbstractEditor.java:333)
        at com.raytheon.viz.ui.editor.VizMultiPaneEditor.addPane(VizMultiPaneEditor.java:112)

mjames-upc avatar Aug 28 '18 16:08 mjames-upc

Interestingly enough, I encountered this on Linux too, so it is not limited to Windows.

The problem is that Java 8 type inference is smarter than Java 7 type inference, and that plugin attempted to compile at 1.7 and failed. Instead of javac, Eclipse uses EJC to compile the plugin, the compile fails with Java 7 but EJC enables compilation to continue regardless of the failure. (The compile error is buried in logs, then you see the result at runtime when that code is invoked).

The compilation succeeds with Java 8 which is why it doesn't show as an error in the Eclipse IDE. This stackoverflow page explains the difference in type inference between 7 and 8 and has useful links that explain it more: https://stackoverflow.com/questions/41744852/how-jdk-8s-type-inference-works-with-generic

My short interpretation is that in Java 7 you can't have inferred generic arguments as an argument to a method (including constructors), but in Java 8 you can. Therefore line 240 does not compile with Java 1.7: defaults = new MapConfiguration(new HashMap<>()); because the diamond operator is used as part of an argument and the compiler can't infer the type. You can also see this in Eclipse if you right click com.raytheon.uf.viz.core and select Properties -> Java Compiler -> Enable project specific settings and set compliance level to 1.7. Then it won't compile.

Two known fixes at this point in time:

  1. Change com.raytheon.uf.viz.core's MANIFEST.MF's Bundle-RequiredExecutionEnvironment from JavaSE-1.7 to JavaSE-1.8.
  2. Update line 240 of HierarchicalPreferenceStore to specify the types, i.e. defaults = new MapConfiguration(new HashMap<String, Object>());

It's not clear to me why the build/export is ignoring the JDK specified in the .product file. If you figure that out, I'd appreciate knowing the solution.

ndjensen avatar Jan 03 '19 00:01 ndjensen