Index: trunk/scripts/TagInfoExtract.java
===================================================================
--- trunk/scripts/TagInfoExtract.java	(revision 19306)
+++ trunk/scripts/TagInfoExtract.java	(revision 19307)
@@ -122,6 +122,4 @@
                 script.new ExternalPresets().run();
                 break;
-            default:
-                throw new IllegalStateException("Invalid type " + script.options.mode);
         }
         if (!script.options.noexit) {
Index: trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 19307)
@@ -233,6 +233,4 @@
             setHelpId(ht("/Action/ZoomToNext"));
             break;
-        default:
-            throw new IllegalArgumentException("Unknown mode: " + mode);
         }
         installAdapters();
Index: trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java	(revision 19307)
@@ -247,5 +247,4 @@
             newCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
             break;
-        default: throw new AssertionError();
         }
         if (newCursor != null) {
Index: trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java	(revision 19307)
@@ -69,10 +69,10 @@
 /**
  * Move is an action that can move all kind of OsmPrimitives (except keys for now).
- *
+ * <p>
  * If an selected object is under the mouse when dragging, move all selected objects.
  * If an unselected object is under the mouse when dragging, it becomes selected
  * and will be moved.
  * If no object is under the mouse, move all selected objects (if any)
- *
+ * <p>
  * On Mac OS X, Ctrl + mouse button 1 simulates right click (map move), so the
  * feature "selection remove" is disabled on this platform.
@@ -402,7 +402,7 @@
      * Look, whether any object is selected. If not, select the nearest node.
      * If there are no nodes in the dataset, do nothing.
-     *
+     * <p>
      * If the user did not press the left mouse button, do nothing.
-     *
+     * <p>
      * Also remember the starting position of the movement and change the mouse
      * cursor to movement.
@@ -465,5 +465,4 @@
             break;
         case SELECT:
-        default:
             if (!(ctrl && PlatformManager.isPlatformOsx())) {
                 // start working with rectangle or lasso
Index: trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java
===================================================================
--- trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java	(revision 19307)
@@ -367,5 +367,5 @@
         }
 
-        MissingMemberStrategy missingMemberStrategy;
+        MissingMemberStrategy missingMemberStrategy = USER_ABORTED; // default case
         if (relationsNeedingMoreMembers.isEmpty()) {
             // The split can be performed without any extra downloads.
@@ -393,5 +393,4 @@
                     break;
                 case ABORT:
-                default:
                     missingMemberStrategy = USER_ABORTED;
                     break;
@@ -419,5 +418,4 @@
                 break;
             case USER_ABORTED:
-            default:
                 return Optional.empty();
             }
Index: trunk/src/org/openstreetmap/josm/data/APIDataSet.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/APIDataSet.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/data/APIDataSet.java	(revision 19307)
@@ -26,5 +26,4 @@
 import org.openstreetmap.josm.data.osm.RelationMember;
 import org.openstreetmap.josm.data.osm.Way;
-import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.Utils;
 
@@ -105,5 +104,5 @@
                     case UPDATE: toUpdate.add(osm); break;
                     case DELETE: toDelete.add(osm); break;
-                    default: Logging.trace("Ignored primitive {0} -> {1}", osm, op);
+                    // Used to have a default case for logging: Logging.trace("Ignored primitive {0} -> {1}", osm, op);
                 }
             }
@@ -228,5 +227,5 @@
      * Adjusts the upload order for new relations. Child relations are uploaded first,
      * parent relations second.
-     *
+     * <p>
      * This method detects cyclic dependencies in new relation. Relations with cyclic
      * dependencies can't be uploaded.
Index: trunk/src/org/openstreetmap/josm/data/Bounds.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/Bounds.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/data/Bounds.java	(revision 19307)
@@ -278,5 +278,4 @@
                 break;
             case MINLAT_MINLON_MAXLAT_MAXLON:
-            default:
                 this.minLat = initLat(values[0], roundToOsmPrecision);
                 this.minLon = initLon(values[1], roundToOsmPrecision);
Index: trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 19307)
@@ -216,4 +216,6 @@
             case CANCELED:
                 tile.loadingCanceled();
+                break;
+            default: // This should be removed when we move to Java 17+
                 // do nothing
             }
Index: trunk/src/org/openstreetmap/josm/data/osm/SimplePrimitiveId.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/SimplePrimitiveId.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/data/osm/SimplePrimitiveId.java	(revision 19307)
@@ -167,6 +167,7 @@
             case RELATION:
                 return "r" + primitive.getUniqueId();
+            default:
+                throw new IllegalArgumentException("Unknown primitive type: " + primitive.getType());
         }
-        throw new IllegalArgumentException("Unknown primitive type: " + primitive.getType());
     }
 }
Index: trunk/src/org/openstreetmap/josm/data/osm/pbf/Blob.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/pbf/Blob.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/data/osm/pbf/Blob.java	(revision 19307)
@@ -98,7 +98,6 @@
             case zlib:
                 return new InflaterInputStream(bais);
-            default:
-                throw new IOException("unknown compression type is not currently supported: " + this.compressionType.name());
         }
+        throw new IOException("unknown compression type is not currently supported: " + this.compressionType.name());
     }
 }
Index: trunk/src/org/openstreetmap/josm/data/projection/proj/LambertAzimuthalEqualArea.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/projection/proj/LambertAzimuthalEqualArea.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/data/projection/proj/LambertAzimuthalEqualArea.java	(revision 19307)
@@ -122,6 +122,4 @@
                 ymf = rq / dd;
                 break;
-            default:
-                throw new AssertionError(mode);
         }
     }
@@ -133,5 +131,9 @@
         final double sinphi = Math.sin(phi);
         double q = qsfn(sinphi);
-        final double sinb, cosb, b, c, x, y;
+        double sinb, cosb, b, c, x, y;
+        // Set c, x, y to 0 until we move to Java 17 where we can use a better switch expression.
+        c = 0;
+        x = 0;
+        y = 0;
         switch (mode) {
             case OBLIQUE:
@@ -173,6 +175,4 @@
                 }
                 break;
-            default:
-                throw new AssertionError(mode);
         }
         if (Math.abs(c) < EPSILON_LATITUDE) {
@@ -192,7 +192,6 @@
             case SOUTH_POLE:
                 return invprojectNS(x, y);
-            default:
-                throw new AssertionError(mode);
-        }
+        }
+        throw new AssertionError(mode);
     }
 
Index: trunk/src/org/openstreetmap/josm/data/validation/Test.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/Test.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/data/validation/Test.java	(revision 19307)
@@ -42,4 +42,5 @@
  * @author frsantos
  */
+@SuppressWarnings("PMD.UnitTestShouldUseTestAnnotation")
 public class Test implements OsmPrimitiveVisitor {
 
Index: trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java	(revision 19307)
@@ -1868,6 +1868,4 @@
         case LOCAL_RO:
             throw new IllegalArgumentException("Cannot update the table: " + table);
-        default:
-            throw new IllegalArgumentException("Unexpected enum value: " + table);
         }
     }
@@ -1881,5 +1879,5 @@
      */
     public static String[] getTLDEntries(ArrayType table) {
-        final String[] array;
+        String[] array = null;
         switch (table) {
         case COUNTRY_CODE_MINUS:
@@ -1907,5 +1905,6 @@
             array = LOCAL_TLDS;
             break;
-        default:
+        }
+        if (array == null) {
             throw new IllegalArgumentException("Unexpected enum value: " + table);
         }
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java	(revision 19307)
@@ -132,4 +132,6 @@
                     decision.getChosenValue(), decision.getKey());
             break;
+        default:
+            throw new AssertionError("Unknown decision type in renderToolTipText(): " + decision.getDecisionType());
         }
         setToolTipText(toolTipText);
@@ -171,6 +173,8 @@
             renderValue(decision);
             return cbDecisionRenderer;
+
+        default:
+            return this;
         }
-        return this;
     }
 }
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionType.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionType.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionType.java	(revision 19307)
@@ -31,7 +31,7 @@
                 return tr("Keep");
             case UNDECIDED:
-            default:
                 return tr("Undecided");
         }
+        return tr("Undecided");
     }
 
@@ -43,7 +43,7 @@
                 return tr("Keep this relation member for the target object");
             case UNDECIDED:
-            default:
                 return tr("Not decided yet");
         }
+        return tr("Not decided yet");
     }
 }
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java	(revision 19307)
@@ -66,4 +66,5 @@
                     comp.setBackground(ConflictColors.BGCOLOR_MEMBER_REMOVE.get());
                     break;
+                default: throw new AssertionError("Unknown decision type: " + model.getDecision(row).getDecision());
                 }
             }
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java	(revision 19307)
@@ -31,5 +31,5 @@
 /**
  * This model manages a list of conflicting relation members.
- *
+ * <p>
  * It can be used as {@link javax.swing.table.TableModel}.
  */
@@ -113,6 +113,6 @@
         case 4: /* decision keep */ return RelationMemberConflictDecisionType.KEEP == d.getDecision();
         case 5: /* decision remove */ return RelationMemberConflictDecisionType.REMOVE == d.getDecision();
-        }
-        return null;
+        default: return null;
+        }
     }
 
@@ -212,5 +212,5 @@
     /**
      * Prepare the default decisions for the current model.
-     *
+     * <p>
      * Keep/delete decisions are made if every member has the same role and the members are in consecutive order within the relation.
      * For multiple occurrences those conditions are tested stepwise for each occurrence.
@@ -222,5 +222,5 @@
     /**
      * Prepare the default decisions for the current model.
-     *
+     * <p>
      * Keep/delete decisions are made if every member has the same role and the members are in consecutive order within the relation.
      * For multiple occurrences those conditions are tested stepwise for each occurrence.
@@ -383,4 +383,5 @@
                     break;
                 case UNDECIDED:
+                default:
                     // FIXME: this is an error
                     break;
@@ -419,4 +420,5 @@
                 break;
             case UNDECIDED:
+            default:
                 // FIXME: handle error
             }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java	(revision 19307)
@@ -197,9 +197,7 @@
                         options[1]
                 );
-                switch (ret) {
-                case JOptionPane.YES_OPTION:
+                if (ret == JOptionPane.YES_OPTION) {
                     buttonAction(1, evt);
-                    break;
-                default:
+                } else {
                     return;
                 }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableCellRenderer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableCellRenderer.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableCellRenderer.java	(revision 19307)
@@ -26,4 +26,5 @@
         case UPDATED: setText(tr("Updated")); break;
         case DELETED: setText(tr("Deleted")); break;
+        default: throw new IllegalStateException("Unexpected value: " + type);
         }
         setToolTipText(null);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java	(revision 19307)
@@ -114,8 +114,8 @@
     @Override
     public Object getValueAt(int row, int col) {
-        switch (col) {
-        case 0: return data.get(row).getModificationType();
-        default: return data.get(row).getPrimitive();
+        if (col == 0) {
+            return data.get(row).getModificationType();
         }
+        return data.get(row).getPrimitive();
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialog.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialog.java	(revision 19307)
@@ -204,4 +204,6 @@
                         return;
                     }
+                default:
+                    throw new IllegalStateException("Unexpected value: " + tpQueryPanels.getSelectedIndex());
                 }
                 setCanceled(false);
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java	(revision 19307)
@@ -248,7 +248,8 @@
         case 2:
             return getWayConnection(rowIndex);
-        }
-        // should not happen
-        return null;
+        default:
+            // should not happen
+            return null;
+        }
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java	(revision 19307)
@@ -135,6 +135,5 @@
                 switch (dialog.getUserAction()) {
                     case PROCEED: return true;
-                    case CANCEL:
-                    default: return false;
+                    case CANCEL: return false;
                 }
             }
@@ -379,8 +378,12 @@
         public void cancel() {
             switch (model.getMode()) {
-            case EDITING_DATA: cancelWhenInEditingModel();
+            case EDITING_DATA:
+                cancelWhenInEditingModel();
                 break;
-            case UPLOADING_AND_SAVING: cancelSafeAndUploadTask();
+            case UPLOADING_AND_SAVING:
+                cancelSafeAndUploadTask();
                 break;
+            default:
+                throw new IllegalStateException("Unexpected value: " + model.getMode());
             }
         }
@@ -428,8 +431,12 @@
                 Mode mode = (Mode) evt.getNewValue();
                 switch (mode) {
-                case EDITING_DATA: setEnabled(true);
-                    break;
-                case UPLOADING_AND_SAVING: setEnabled(false);
-                    break;
+                case EDITING_DATA:
+                    setEnabled(true);
+                    break;
+                case UPLOADING_AND_SAVING:
+                    setEnabled(false);
+                    break;
+                default:
+                    throw new IllegalStateException("Unexpected value: " + mode);
                 }
             }
@@ -525,8 +532,12 @@
                 SaveLayersModel.Mode mode = (SaveLayersModel.Mode) evt.getNewValue();
                 switch (mode) {
-                case EDITING_DATA: setEnabled(true);
-                    break;
-                case UPLOADING_AND_SAVING: setEnabled(false);
-                    break;
+                case EDITING_DATA:
+                    setEnabled(true);
+                    break;
+                case UPLOADING_AND_SAVING:
+                    setEnabled(false);
+                    break;
+                default:
+                    throw new IllegalStateException("Unexpected value: " + mode);
                 }
             }
Index: trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTable.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTable.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTable.java	(revision 19307)
@@ -27,8 +27,12 @@
             Mode mode = (Mode) evt.getNewValue();
             switch (mode) {
-            case EDITING_DATA: setEnabled(true);
-            break;
-            case UPLOADING_AND_SAVING: setEnabled(false);
-            break;
+            case EDITING_DATA:
+                setEnabled(true);
+                break;
+            case UPLOADING_AND_SAVING:
+                setEnabled(false);
+                break;
+            default:
+                throw new IllegalStateException("Unexpected value: " + mode);
             }
         }
Index: trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java	(revision 19307)
@@ -401,5 +401,4 @@
                     switch (strategy.getPolicy()) {
                     case ABORT:
-                        break; /* do nothing - we return to map editing */
                     case AUTOMATICALLY_OPEN_NEW_CHANGESETS:
                         break; /* do nothing - we return to map editing */
@@ -411,4 +410,6 @@
                         UploadDialog.getUploadDialog().setVisible(true);
                         break;
+                    default:
+                        throw new IllegalStateException("Unexpected value: " + strategy.getPolicy());
                     }
                 } else {
Index: trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java	(revision 19307)
@@ -39,5 +39,5 @@
 /**
  * UploadStrategySelectionPanel is a panel for selecting an upload strategy.
- *
+ * <p>
  * Clients can listen for property change events for the property
  * {@link #UPLOAD_STRATEGY_SPECIFICATION_PROP}.
@@ -394,4 +394,6 @@
                 tfChunkSize.requestFocusInWindow();
                 break;
+            case SINGLE_REQUEST_STRATEGY:
+            case INDIVIDUAL_OBJECTS_STRATEGY:
             default:
                 tfChunkSize.setEnabled(false);
Index: trunk/src/org/openstreetmap/josm/gui/layer/CustomizeColor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/CustomizeColor.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/layer/CustomizeColor.java	(revision 19307)
@@ -27,5 +27,5 @@
 /**
  * Action to show a dialog for picking a color.
- *
+ * <p>
  * By calling this action, the user can choose a color to customize the painting
  * of a certain {@link GpxLayer} or {@link org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer}.
@@ -84,12 +84,14 @@
         );
         switch (answer) {
-        case 0:
+        case JOptionPane.OK_OPTION:
             colorLayers.forEach(l -> l.setColor(c.getColor()));
             break;
-        case 1:
+        case JOptionPane.NO_OPTION:
             return;
-        case 2:
+        case JOptionPane.CANCEL_OPTION:
             colorLayers.forEach(l -> l.setColor(null));
             break;
+        default:
+            throw new IllegalStateException("Unexpected value: " + answer);
         }
         // TODO: Make the layer dialog listen to property change events so that this is not needed any more.
Index: trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java	(revision 19307)
@@ -115,13 +115,15 @@
         );
         switch (answer) {
-        case 0:
+        case JOptionPane.OK_OPTION:
             tracks.forEach(t -> t.setColor(c.getColor()));
             GPXSettingsPanel.putLayerPrefLocal(layer, "colormode", "0"); //set Colormode to none
             break;
-        case 1:
+        case JOptionPane.NO_OPTION:
             return;
-        case 2:
+        case JOptionPane.CANCEL_OPTION:
             tracks.forEach(t -> t.setColor(null));
             break;
+        default:
+            throw new InvalidArgumentException("Unknown choice: " + answer);
         }
         table.repaint();
Index: trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulFilter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulFilter.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulFilter.java	(revision 19307)
@@ -106,6 +106,6 @@
                     alphaOffset, src.getAlphaRaster() != null);
             return dest;
-        }
-
+        default: // Fall through
+        }
         return doFilterRGB(src);
     }
Index: trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java	(revision 19307)
@@ -138,10 +138,8 @@
         double scaleMapView = MainApplication.getMap().mapView.getScale();
         ImageWarp.Interpolation interpolation;
-        switch (Config.getPref().get("imagery.warp.pixel-interpolation", "bilinear")) {
-            case "nearest_neighbor":
-                interpolation = ImageWarp.Interpolation.NEAREST_NEIGHBOR;
-                break;
-            default:
-                interpolation = ImageWarp.Interpolation.BILINEAR;
+        if (Config.getPref().get("imagery.warp.pixel-interpolation", "bilinear").equals("nearest_neighbor")) {
+            interpolation = ImageWarp.Interpolation.NEAREST_NEIGHBOR;
+        } else {
+            interpolation = ImageWarp.Interpolation.BILINEAR;
         }
 
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java	(revision 19307)
@@ -423,9 +423,7 @@
 
     private static Float computeWidth(LineType type, Cascade c, Cascade cDef) {
-        Float width;
         switch (type) {
             case NORMAL:
-                width = getWidth(c, WIDTH, getWidth(cDef, WIDTH, null));
-                break;
+                return getWidth(c, WIDTH, getWidth(cDef, WIDTH, null));
             case CASING:
                 Float casingWidth = c.get(type.prefix + WIDTH, null, Float.class, true);
@@ -438,14 +436,10 @@
                 if (casingWidth == null)
                     return null;
-                width = Optional.ofNullable(getWidth(c, WIDTH, getWidth(cDef, WIDTH, null))).orElse(0f) + 2 * casingWidth;
-                break;
+                return Optional.ofNullable(getWidth(c, WIDTH, getWidth(cDef, WIDTH, null))).orElse(0f) + 2 * casingWidth;
             case LEFT_CASING:
             case RIGHT_CASING:
-                width = getWidth(c, type.prefix + WIDTH, null);
-                break;
-            default:
-                throw new AssertionError();
-        }
-        return width;
+                return getWidth(c, type.prefix + WIDTH, null);
+        }
+        throw new AssertionError();
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java	(revision 19307)
@@ -282,7 +282,6 @@
         case KEY_VALUE_REQUIRED:
             return tags.containsKey(key) && getValues().contains(tags.get(key));
-        default:
-            throw new IllegalStateException();
-        }
+        }
+        throw new IllegalStateException();
     }
 
Index: trunk/src/org/openstreetmap/josm/io/AbstractReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/AbstractReader.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/io/AbstractReader.java	(revision 19307)
@@ -523,10 +523,9 @@
 
     protected final void parseVersion(PrimitiveData current, int version) throws IllegalDataException {
-        switch (ds.getVersion()) {
-        case "0.6":
+        if (ds.getVersion().equals("0.6")) {
             if (version <= 0 && !current.isNew()) {
                 throw new IllegalDataException(
                         tr("Illegal value for attribute ''version'' on OSM primitive with ID {0}. Got {1}.",
-                        Long.toString(current.getUniqueId()), version));
+                                Long.toString(current.getUniqueId()), version));
             } else if (version < 0 && current.isNew()) {
                 Logging.warn(tr("Normalizing value of attribute ''version'' of element {0} to {2}, API version is ''{3}''. Got {1}.",
@@ -534,7 +533,5 @@
                 version = 0;
             }
-            break;
-        default:
-            // should not happen. API version has been checked before
+        } else { // should not happen. API version has been checked before
             throw new IllegalDataException(tr("Unknown or unsupported API version. Got {0}.", ds.getVersion()));
         }
Index: trunk/src/org/openstreetmap/josm/io/Compression.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/Compression.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/io/Compression.java	(revision 19307)
@@ -103,7 +103,7 @@
                 return getXZInputStream(in);
             case NONE:
-            default:
                 return in;
         }
+        return in;
     }
 
@@ -219,7 +219,7 @@
                 return new XZCompressorOutputStream(out);
             case NONE:
-            default:
                 return out;
         }
+        return out;
     }
 
Index: trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java	(revision 19307)
@@ -254,7 +254,7 @@
                 return NO_PROXY_LIST;
             return Collections.singletonList(new Proxy(Type.SOCKS, socksProxySocketAddress));
-        }
         // should not happen
-        return Collections.emptyList();
+        default: return Collections.emptyList();
+        }
     }
 }
Index: trunk/src/org/openstreetmap/josm/io/OnlineResource.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OnlineResource.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/io/OnlineResource.java	(revision 19307)
@@ -57,7 +57,6 @@
             case ALL:
                 return /* ICON() */ "offline_all";
-            default:
-                return null;
         }
+        return null;
     }
 
Index: trunk/src/org/openstreetmap/josm/io/OsmChangeReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmChangeReader.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/io/OsmChangeReader.java	(revision 19307)
@@ -111,10 +111,8 @@
             int event = parser.next();
             if (event == XMLStreamConstants.START_ELEMENT) {
-                switch (parser.getLocalName()) {
-                case "comment":
+                if (parser.getLocalName().equals("comment")) {
                     text = parser.getAttributeValue(null, "text");
                     jumpToEnd();
-                    break;
-                default:
+                } else {
                     parseUnknown();
                 }
Index: trunk/src/org/openstreetmap/josm/io/UploadStrategySpecification.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/UploadStrategySpecification.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/io/UploadStrategySpecification.java	(revision 19307)
@@ -7,5 +7,5 @@
  * An UploadStrategySpecification consists of the parameter describing the strategy
  * for uploading a collection of {@link org.openstreetmap.josm.data.osm.OsmPrimitive}.
- *
+ * <p>
  * This includes:
  * <ul>
@@ -145,4 +145,5 @@
             else
                 return (int) Math.ceil((double) numObjects / (double) chunkSize);
+        default: // do nothing
         }
         // should not happen
Index: trunk/src/org/openstreetmap/josm/io/audio/AudioPlayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/audio/AudioPlayer.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/io/audio/AudioPlayer.java	(revision 19307)
@@ -344,5 +344,4 @@
                             stateChange = State.PAUSED;
                             break;
-                        default: // Do nothing
                     }
                     command.ok(stateChange);
Index: trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 19307)
@@ -85,10 +85,10 @@
 /**
  * Helper class to support the application with images.
- *
+ * <p>
  * How to use:
- *
+ * <p>
  * <code>ImageIcon icon = new ImageProvider(name).setMaxSize(ImageSizes.MAP).get();</code>
  * (there are more options, see below)
- *
+ * <p>
  * short form:
  * <code>ImageIcon icon = ImageProvider.get(name);</code>
@@ -247,4 +247,9 @@
     }
 
+    private enum ImageLocations {
+        LOCAL,
+        ARCHIVE
+    }
+
     /**
      * Property set on {@code BufferedImage} returned by {@link #makeImageTransparent}.
@@ -372,5 +377,5 @@
     /**
      * Specify a zip file where the image is located.
-     *
+     * <p>
      * (optional)
      * @param archive zip file where the image is located
@@ -384,7 +389,7 @@
     /**
      * Specify a base path inside the zip file.
-     *
+     * <p>
      * The subdir and name will be relative to this path.
-     *
+     * <p>
      * (optional)
      * @param inArchiveDir path inside the archive
@@ -413,5 +418,5 @@
     /**
      * Set the dimensions of the image.
-     *
+     * <p>
      * If not specified, the original size of the image is used.
      * The width part of the dimension can be -1. Then it will only set the height but
@@ -428,5 +433,5 @@
     /**
      * Set the dimensions of the image.
-     *
+     * <p>
      * If not specified, the original size of the image is used.
      * @param size final dimensions of the image
@@ -476,8 +481,8 @@
     /**
      * Limit the maximum size of the image.
-     *
+     * <p>
      * It will shrink the image if necessary, but keep the aspect ratio.
      * The given width or height can be -1 which means this direction is not bounded.
-     *
+     * <p>
      * 'size' and 'maxSize' are not compatible, you should set only one of them.
      * @param maxSize maximum image size
@@ -492,8 +497,8 @@
     /**
      * Limit the maximum size of the image.
-     *
+     * <p>
      * It will shrink the image if necessary, but keep the aspect ratio.
      * The given width or height can be -1 which means this direction is not bounded.
-     *
+     * <p>
      * This function sets value using the most restrictive of the new or existing set of
      * values.
@@ -515,8 +520,8 @@
     /**
      * Limit the maximum size of the image.
-     *
+     * <p>
      * It will shrink the image if necessary, but keep the aspect ratio.
      * The given width or height can be -1 which means this direction is not bounded.
-     *
+     * <p>
      * 'size' and 'maxSize' are not compatible, you should set only one of them.
      * @param size maximum image size
@@ -561,5 +566,5 @@
     /**
      * Decide, if an exception should be thrown, when the image cannot be located.
-     *
+     * <p>
      * Set to true, when the image URL comes from user data and the image may be missing.
      *
@@ -575,5 +580,5 @@
     /**
      * Suppresses warning on the command line in case the image cannot be found.
-     *
+     * <p>
      * In combination with setOptional(true);
      * @param suppressWarnings if <code>true</code> warnings are suppressed
@@ -667,5 +672,5 @@
     /**
      * Load the image in a background thread.
-     *
+     * <p>
      * This method returns immediately and runs the image request asynchronously.
      * @param action the action that will deal with the image
@@ -712,5 +717,5 @@
     /**
      * Load the image in a background thread.
-     *
+     * <p>
      * This method returns immediately and runs the image request asynchronously.
      * @param action the action that will deal with the image
@@ -884,7 +889,5 @@
             extensions = new String[] {".png", ".svg"};
         }
-        final int typeArchive = 0;
-        final int typeLocal = 1;
-        for (int place : new Integer[] {typeArchive, typeLocal}) {
+        for (ImageLocations place : ImageLocations.values()) {
             for (String ext : extensions) {
 
@@ -906,5 +909,5 @@
 
                 switch (place) {
-                case typeArchive:
+                case ARCHIVE:
                     if (archive != null) {
                         cacheName = "zip:" + archive.hashCode() + ':' + cacheName;
@@ -919,5 +922,5 @@
                     }
                     break;
-                case typeLocal:
+                case LOCAL:
                     ImageResource ir = cache.get(cacheName);
                     if (ir != null) return ir;
@@ -956,5 +959,5 @@
             switch (type) {
             case SVG:
-                SVGDiagram svg = null;
+                SVGDiagram svg;
                 synchronized (getSvgUniverse()) {
                     URI uri = getSvgUniverse().loadSVG(is, Utils.fileToURL(cf.getFile()).toString());
@@ -970,6 +973,4 @@
                 }
                 return img == null ? null : new ImageResource(img);
-            default:
-                throw new AssertionError("Unsupported type: " + type);
             }
         } catch (IOException e) {
@@ -977,4 +978,5 @@
             return null;
         }
+        throw new AssertionError("Unsupported type: " + type);
     }
 
@@ -1082,4 +1084,5 @@
      */
     private static ImageResource getIfAvailableZip(String fullName, File archive, String inArchiveDir, ImageType type) {
+        Objects.requireNonNull(type, "ImageType must not be null");
         try (ZipFile zipFile = new ZipFile(archive, StandardCharsets.UTF_8)) {
             if (inArchiveDir == null || ".".equals(inArchiveDir)) {
@@ -1097,5 +1100,5 @@
                     switch (type) {
                     case SVG:
-                        SVGDiagram svg = null;
+                        SVGDiagram svg;
                         synchronized (getSvgUniverse()) {
                             URI uri = getSvgUniverse().loadSVG(is, entryName, true);
@@ -1116,6 +1119,4 @@
                         }
                         return img == null ? null : new ImageResource(img);
-                    default:
-                        throw new AssertionError("Unknown ImageType: "+type);
                     }
                 }
@@ -1135,4 +1136,5 @@
      */
     private static ImageResource getIfAvailableLocalURL(URL path, ImageType type) {
+        Objects.requireNonNull(type, "ImageType must not be null");
         switch (type) {
         case SVG:
@@ -1174,7 +1176,7 @@
             }
             return img == null ? null : new ImageResource(img);
-        default:
-            throw new AssertionError();
-        }
+        }
+        // Default
+        throw new AssertionError();
     }
 
@@ -1379,6 +1381,6 @@
      * one-step technique (only useful in downscaling cases, where {@code targetWidth} or {@code targetHeight} is
      * smaller than the original dimensions, and generally only when the {@code BILINEAR} hint is specified).
-     *
-     * From https://community.oracle.com/docs/DOC-983611: "The Perils of Image.getScaledInstance()"
+     * <p>
+     * From <a href="https://community.oracle.com/docs/DOC-983611">"The Perils of Image.getScaledInstance()"</a>
      *
      * @param img the original image to be scaled
Index: trunk/src/org/openstreetmap/josm/tools/ImageWarp.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/ImageWarp.java	(revision 19306)
+++ trunk/src/org/openstreetmap/josm/tools/ImageWarp.java	(revision 19307)
@@ -164,4 +164,5 @@
      */
     public static BufferedImage warp(BufferedImage srcImg, Dimension targetDim, PointTransform invTransform, Interpolation interpolation) {
+        Objects.requireNonNull(interpolation, "interpolation");
         BufferedImage imgTarget = new BufferedImage(targetDim.width, targetDim.height, BufferedImage.TYPE_INT_ARGB);
         Rectangle2D srcRect = new Rectangle2D.Double(0, 0, srcImg.getWidth(), srcImg.getHeight());
@@ -175,5 +176,6 @@
                 Point2D srcCoord = invTransform.transform(i, j);
                 if (srcRect.contains(srcCoord)) {
-                    int rgba;
+                    // Convert to switch expression when we switch to Java 17+.
+                    int rgba = 0; // Initialized here so the compiler doesn't complain. Otherwise, BILINEAR needs to have it start at 0.
                     switch (interpolation) {
                         case NEAREST_NEIGHBOR:
@@ -189,5 +191,5 @@
                             int c10 = getColor(x0 + 1, y0, srcImg, sharedArray);
                             int c11 = getColor(x0 + 1, y0 + 1, srcImg, sharedArray);
-                            rgba = 0;
+                            // rgba
                             // loop over color components: blue, green, red, alpha
                             for (int ch = 0; ch <= 3; ch++) {
@@ -199,6 +201,4 @@
                             }
                             break;
-                        default:
-                            throw new AssertionError(Objects.toString(interpolation));
                     }
                     imgTarget.getRaster().setDataElements(i, j, imgTarget.getColorModel().getDataElements(rgba, pixel));
