Modify

Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#22615 closed defect (fixed)

Concurrent ExecutionException while running jar with IntelliJ coverage

Reported by: gaben Owned by: team
Priority: minor Milestone:
Component: Wiki content Version:
Keywords: intellij coverage Cc:

Description (last modified by gaben)

What steps will reproduce the problem?

  1. Download the latest JOSM jar (r18621 currently)
  2. Create a run configuration with the JAR
  3. Run IntelliJ's default coverage task

(IntelliJ IDEA 2022.3.1 Build #IU-223.8214.52, built on December 20, 2022)

What is the expected result?

No exception, JOSM loading in without errors.

What happens instead?

The exception detailed below and JOSM loading is stopping at the imagery load task.

Please provide any additional information below. Attach a screenshot if possible.

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2022-12-28 19:38:17 +0100 (Wed, 28 Dec 2022)
Revision:18621
Build-Date:2022-12-29 02:30:57
URL:https://josm.openstreetmap.de/svn/trunk

Identification: JOSM/1.5 (18621 hu) Linux Ubuntu 20.04.5 LTS
Memory Usage: 309 MB / 2480 MB (128 MB allocated, but free)
Java version: 11.0.17+8-post-Ubuntu-1ubuntu220.04, Ubuntu, OpenJDK 64-Bit Server VM
Look and Feel: javax.swing.plaf.metal.MetalLookAndFeel
Screen: :0.0 1918×1020 (scaling 1.00×1.00)
Maximum Screen Size: 1918×1020
Best cursor sizes: 16×16→16×16, 32×32→32×32
Environment variable LANG: hu_HU.UTF-8
System property file.encoding: UTF-8
System property sun.jnu.encoding: UTF-8
Locale info: hu_HU
Numbers with default locale: 1234567890 -> 1234567890
Desktop environment: ubuntu:GNOME
Java package: openjdk-11-jre:amd64-11.0.17+8-1ubuntu2~20.04
Java ATK Wrapper package: libatk-wrapper-java:all-0.37.1-1
fonts-noto: fonts-noto:-
VM arguments: [-javaagent:/home/<redacted>/progs/idea/lib/intellij-coverage-agent-1.0.682.jar=/tmp/coverage2args, -Didea.new.sampling.coverage=true, -Dcoverage.ignore.private.constructor.util.class=true, -Dfile.encoding=UTF-8]

Plugins:
+ continuosDownload

Last errors/warnings:
- 00005.172 E: Handled by bug report queue: org.openstreetmap.josm.tools.JosmRuntimeException: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError. Indok: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError. Indok: java.lang.ExceptionInInitializerError. Indok: java.lang.ClassCastException: class [I cannot be cast to class java.lang.String ([I and java.lang.String are in module java.base of loader 'bootstrap')



=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: main (1)
org.openstreetmap.josm.tools.JosmRuntimeException: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
	at org.openstreetmap.josm.spi.lifecycle.Lifecycle.initialize(Lifecycle.java:93)
	at org.openstreetmap.josm.gui.MainApplication.mainJOSM(MainApplication.java:959)
	at org.openstreetmap.josm.gui.MainApplication$3.processArguments(MainApplication.java:277)
	at org.openstreetmap.josm.gui.MainApplication.main(MainApplication.java:742)
Caused by: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at org.openstreetmap.josm.spi.lifecycle.Lifecycle.initialize(Lifecycle.java:78)
	... 3 more
Caused by: java.lang.ExceptionInInitializerError
	at org.openstreetmap.josm.gui.mappaint.MapPaintStyles.fromSourceEntry(MapPaintStyles.java:343)
	at org.openstreetmap.josm.gui.mappaint.MapPaintStyles.readFromPreferences(MapPaintStyles.java:297)
	at org.openstreetmap.josm.gui.preferences.map.MapPaintPreference.initialize(MapPaintPreference.java:198)
	at org.openstreetmap.josm.spi.lifecycle.InitializationTask.call(InitializationTask.java:33)
	at org.openstreetmap.josm.spi.lifecycle.InitializationTask.call(InitializationTask.java:11)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ClassCastException: class [I cannot be cast to class java.lang.String ([I and java.lang.String are in module java.base of loader 'bootstrap')
	at org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource.<clinit>(MapCSSStyleSource.java:99)
	... 9 more

Attachments (0)

Change History (8)

comment:1 by gaben, 17 months ago

Description: modified (diff)

add IntelliJ version info

comment:2 by taylor.smock, 17 months ago

The problem here is that IntelliJ adds fields to classes, which are not of the expected String type. The workaround (in source) is very simple; just add a wrapper if (<var> instanceof String) in MapCSSStyleSource. I've done it locally, but I have never pushed it, since it is a specific workaround for a specific run configuration.

comment:3 by gaben, 17 months ago

Keywords: intellij coverage added

comment:4 by taylor.smock, 17 months ago

Here is what I use to work around the issue of IDEA adding fields to objects when running with coverage:

  • src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    diff --git a/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java b/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
    a b  
    9696    static {
    9797        for (Field f : StyleKeys.class.getDeclaredFields()) {
    9898            try {
    99                 SUPPORTED_KEYS.add((String) f.get(null));
    100                 if (!f.getName().toLowerCase(Locale.ENGLISH).replace('_', '-').equals(f.get(null))) {
    101                     throw new JosmRuntimeException(f.getName());
     99                Object object = f.get(null);
     100                // Some coverage runners add new fields to objects. ("__$lineHits$__" from IDEA for example)
     101                if (object instanceof String) {
     102                    SUPPORTED_KEYS.add((String) object);
     103                    if (!f.getName().toLowerCase(Locale.ENGLISH).replace('_', '-').equals(f.get(null))) {
     104                        throw new JosmRuntimeException(f.getName());
     105                    }
    102106                }
    103107            } catch (IllegalArgumentException | IllegalAccessException ex) {
    104108                throw new JosmRuntimeException(ex);
Last edited 17 months ago by taylor.smock (previous) (diff)

comment:5 by gaben, 17 months ago

Thanks, it's working. Thinking about where to put the patch as we don't have idea directory inside tools. Maybe put in the wiki?

comment:6 by gaben, 17 months ago

Description: modified (diff)

trim log

comment:7 by taylor.smock, 17 months ago

Component: CoreWiki content
Resolution: fixed
Status: newclosed

comment:8 by gaben, 17 months ago

Thank you! :)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.