Changeset 10208 in josm for trunk/src/org/openstreetmap/josm
- Timestamp:
- 2016-05-14T02:38:41+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r10044 r10208 954 954 if (klass != null && LookAndFeel.class.isAssignableFrom(klass)) { 955 955 try { 956 UIManager.setLookAndFeel((LookAndFeel) klass.newInstance()); 957 } catch (Exception ex) { 956 UIManager.setLookAndFeel((LookAndFeel) klass.getConstructor().newInstance()); 957 } catch (ReflectiveOperationException ex) { 958 958 warn("Cannot set Look and Feel: " + laf + ": "+ex.getMessage()); 959 959 } -
trunk/src/org/openstreetmap/josm/actions/ExtensionFileFilter.java
r9968 r10208 65 65 for (final Class<? extends FileImporter> importerClass : importerNames) { 66 66 try { 67 FileImporter importer = importerClass.newInstance(); 67 FileImporter importer = importerClass.getConstructor().newInstance(); 68 68 importers.add(importer); 69 69 MapView.addLayerChangeListener(importer); 70 } catch (Exception e) { 70 } catch (ReflectiveOperationException e) { 71 71 if (Main.isDebugEnabled()) { 72 72 Main.debug(e.getMessage()); … … 106 106 for (final Class<? extends FileExporter> exporterClass : exporterClasses) { 107 107 try { 108 FileExporter exporter = exporterClass.newInstance(); 108 FileExporter exporter = exporterClass.getConstructor().newInstance(); 109 109 exporters.add(exporter); 110 110 MapView.addLayerChangeListener(exporter); 111 } catch (Exception e) { 111 } catch (ReflectiveOperationException e) { 112 112 if (Main.isDebugEnabled()) { 113 113 Main.debug(e.getMessage()); -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r10181 r10208 1209 1209 T structPrototype; 1210 1210 try { 1211 structPrototype = klass.newInstance(); 1212 } catch ( InstantiationException | IllegalAccessException ex) {1211 structPrototype = klass.getConstructor().newInstance(); 1212 } catch (ReflectiveOperationException ex) { 1213 1213 throw new RuntimeException(ex); 1214 1214 } … … 1258 1258 T struct = null; 1259 1259 try { 1260 struct = klass.newInstance(); 1261 } catch ( InstantiationException | IllegalAccessException ex) {1260 struct = klass.getConstructor().newInstance(); 1261 } catch (ReflectiveOperationException ex) { 1262 1262 throw new RuntimeException(ex); 1263 1263 } 1264 1264 for (Entry<String, String> key_value : hash.entrySet()) { 1265 Object value = null;1265 Object value; 1266 1266 Field f; 1267 1267 try { -
trunk/src/org/openstreetmap/josm/data/projection/proj/ClassProjFactory.java
r9067 r10208 9 9 private final Class<? extends Proj> projClass; 10 10 11 /** 12 * Constructs a new {@code ClassProjFactory}. 13 * @param projClass projection class 14 */ 11 15 public ClassProjFactory(Class<? extends Proj> projClass) { 12 16 this.projClass = projClass; … … 17 21 Proj proj = null; 18 22 try { 19 proj = projClass.newInstance(); 20 } catch ( InstantiationException | IllegalAccessException e) {23 proj = projClass.getConstructor().newInstance(); 24 } catch (ReflectiveOperationException e) { 21 25 throw new RuntimeException(e); 22 26 } -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r9989 r10208 136 136 for (Class<Test> testClass : allAvailableTests) { 137 137 try { 138 allTestsMap.put(testClass.getName(), testClass.newInstance()); 139 } catch (Exception e) { 138 allTestsMap.put(testClass.getName(), testClass.getConstructor().newInstance()); 139 } catch (ReflectiveOperationException e) { 140 140 Main.error(e); 141 141 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java
r10001 r10208 220 220 } else { 221 221 // create handler object 222 RequestHandler handler = handlerClass.newInstance(); 222 RequestHandler handler = handlerClass.getConstructor().newInstance(); 223 223 try { 224 224 handler.setCommand(command); … … 243 243 } catch (IOException ioe) { 244 244 Main.debug(Main.getErrorMessage(ioe)); 245 } catch (Exception e) { 245 } catch (ReflectiveOperationException e) { 246 246 Main.error(e); 247 247 try { … … 391 391 public static String getHandlerInfoAsJSON(String cmd) { 392 392 try (StringWriter w = new StringWriter()) { 393 PrintWriter r = new PrintWriter(w);394 393 RequestHandler handler = null; 395 394 try { 396 395 Class<?> c = handlers.get(cmd); 397 396 if (c == null) return null; 398 handler = handlers.get(cmd).newInstance(); 399 } catch ( InstantiationException | IllegalAccessException ex) {397 handler = handlers.get(cmd).getConstructor().newInstance(); 398 } catch (ReflectiveOperationException ex) { 400 399 Main.error(ex); 401 400 return null; 402 401 } 403 402 403 PrintWriter r = new PrintWriter(w); 404 404 printJsonInfo(cmd, r, handler); 405 405 return w.toString(); … … 459 459 * Reports HTML message with the description of all available commands 460 460 * @return HTML message with the description of all available commands 461 * @throws IllegalAccessException if one handler class or its nullary constructor is not accessible. 462 * @throws InstantiationException if one handler class represents an abstract class, an interface, an array class, 463 * a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason. 464 */ 465 public static String getUsageAsHtml() throws IllegalAccessException, InstantiationException { 461 * @throws ReflectiveOperationException if a reflective operation fails for one handler class 462 */ 463 public static String getUsageAsHtml() throws ReflectiveOperationException { 466 464 StringBuilder usage = new StringBuilder(1024); 467 465 for (Entry<String, Class<? extends RequestHandler>> handler : handlers.entrySet()) { 468 RequestHandler sample = handler.getValue().newInstance(); 466 RequestHandler sample = handler.getValue().getConstructor().newInstance(); 469 467 String[] mandatory = sample.getMandatoryParams(); 470 468 String[] optional = sample.getOptionalParams(); -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r9746 r10208 99 99 SessionLayerImporter importer = null; 100 100 try { 101 importer = importerClass.newInstance(); 102 } catch ( InstantiationException | IllegalAccessException e) {101 importer = importerClass.getConstructor().newInstance(); 102 } catch (ReflectiveOperationException e) { 103 103 throw new RuntimeException(e); 104 104 } -
trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java
r9983 r10208 83 83 Class<?> klass = mapping.get(qname).klass; 84 84 try { 85 current.push(klass.newInstance()); 86 } catch (Exception e) { 85 current.push(klass.getConstructor().newInstance()); 86 } catch (ReflectiveOperationException e) { 87 87 throwException(e); 88 88 }
Note:
See TracChangeset
for help on using the changeset viewer.