diff --git a/src/java/org/web3d/vrml/renderer/CRProtoCreator.java b/src/java/org/web3d/vrml/renderer/CRProtoCreator.java index bc14a8731d657068661c17e92abf61055ef8b0d8..aac5a861c8c2de15bf0e768e2fdd36ccc8ca3c4d 100644 --- a/src/java/org/web3d/vrml/renderer/CRProtoCreator.java +++ b/src/java/org/web3d/vrml/renderer/CRProtoCreator.java @@ -351,13 +351,13 @@ public abstract class CRProtoCreator */ private void processDEFs(Map<String, VRMLNode> defMappings) { Set<Entry<String, VRMLNode>> def_set = defMappings.entrySet(); - Iterator<Entry<String, VRMLNode>> itr = def_set.iterator(); - - while(itr.hasNext()) { - Map.Entry<String, VRMLNode> e = itr.next(); - String name = e.getKey(); - VRMLNodeType src_node = (VRMLNodeType) e.getValue(); - VRMLNodeType dest_node = (VRMLNodeType) nodeMap.get(src_node); + String name; + VRMLNodeType src_node; + VRMLNodeType dest_node; + for (Entry<String, VRMLNode> e : def_set) { + name = e.getKey(); + src_node = (VRMLNodeType) e.getValue(); + dest_node = (VRMLNodeType) nodeMap.get(src_node); scene.addDEFNode(name, dest_node); } @@ -379,21 +379,27 @@ public abstract class CRProtoCreator Map<String, VRMLNode> def_map = scene.getDEFNodes(); Map<String, Map<String, VRMLNode>> export_map = new HashMap<>(); + Map.Entry<String, VRMLNode> e; + ImportNodeProxy value; + String key, inline; + ImportNodeProxy proxy; + Map<String, VRMLNode> exports; + VRMLInlineNodeType i_node; while(itr.hasNext()) { - Map.Entry<String, VRMLNode> e = itr.next(); + e = itr.next(); try { - ImportNodeProxy value = (ImportNodeProxy)e.getValue(); - String key = e.getKey(); + value = (ImportNodeProxy)e.getValue(); + key = e.getKey(); - ImportNodeProxy proxy = (ImportNodeProxy)value.clone(); + proxy = (ImportNodeProxy)value.clone(); - String inline = value.getInlineDEFName(); - Map<String, VRMLNode> exports = export_map.get(inline); + inline = value.getInlineDEFName(); + exports = export_map.get(inline); if(exports == null) { exports = new HashMap<>(); export_map.put(inline, exports); - VRMLInlineNodeType i_node = (VRMLInlineNodeType)def_map.get(inline); + i_node = (VRMLInlineNodeType)def_map.get(inline); i_node.setImportNodes(exports); } diff --git a/src/java/org/web3d/vrml/renderer/ogl/OGLExternPrototypeDecl.java b/src/java/org/web3d/vrml/renderer/ogl/OGLExternPrototypeDecl.java index 19b723023285a0350d6858f403cb79c128be26a6..5c325aa8e9484c9044c200b165d6f355fdf4a490 100644 --- a/src/java/org/web3d/vrml/renderer/ogl/OGLExternPrototypeDecl.java +++ b/src/java/org/web3d/vrml/renderer/ogl/OGLExternPrototypeDecl.java @@ -97,8 +97,7 @@ public class OGLExternPrototypeDecl extends CRExternPrototypeDecl { "No matching PROTO instances in " + scene.getLoadedURI() + " to match this EXTERNPROTO " + getVRMLNodeName()); - VRMLWorldRootNodeType root = - (VRMLWorldRootNodeType)scene.getRootNode(); + VRMLWorldRootNodeType root = (VRMLWorldRootNodeType)scene.getRootNode(); setProtoDetails(proto_def); OGLProtoCreator creator = diff --git a/src/java/org/xj3d/core/loading/ContentLoader.java b/src/java/org/xj3d/core/loading/ContentLoader.java index 0f1c99341a7d0e03f8ddc9f9a434d4acdb271384..54a8136e88e9f46291ef868e7d00c41c4dce119b 100644 --- a/src/java/org/xj3d/core/loading/ContentLoader.java +++ b/src/java/org/xj3d/core/loading/ContentLoader.java @@ -39,19 +39,19 @@ class ContentLoader implements Runnable /** Message for an unexpected exception message */ private static final String UNEXPECTED_EXCEPTION_MSG = "[ContentLoader] unexpected Xj3D exception during model loading"; - - private static final String Xj3D_ISSUE_LIST = + + private static final String XJ3D_ISSUE_LIST = "New Xj3D issue needed to improve the open source, please see\n" + " https://gitlab.nps.edu/Savage/xj3d/issues"; - + /** The threading running this loader */ private Thread thread; /** The list of data we are fetching from */ - private ContentLoadQueue pendingContentLoadQueue; + private final ContentLoadQueue pendingContentLoadQueue; /** The map of nodes we are currently loading to their loader */ - private Map<String[], LoadRequest> inProgressLoadRequestMap; + private final Map<String[], LoadRequest> inProgressLoadRequestMap; /** Flag indicating that the current load should be terminated */ private boolean terminateCurrent; @@ -117,19 +117,19 @@ class ContentLoader implements Runnable // Register now that we are processing this object inProgressLoadRequestMap.put(currentLoadRequest.url, currentLoadRequest); - + currentLoadRequest.loadRequestHandler.processLoadRequest(errorReporter, currentLoadRequest.url, currentLoadRequest.loadDetailsList); // Register now that we finished processing this object inProgressLoadRequestMap.remove(currentLoadRequest.url); - } - catch (Exception e) + } + catch (Exception e) { // Any other exception // System.out.println ("ContentLoader exception:"); // debug errorReporter.errorReport (UNEXPECTED_EXCEPTION_MSG, e); - errorReporter.messageReport(Xj3D_ISSUE_LIST); + errorReporter.messageReport(XJ3D_ISSUE_LIST); // e.printStackTrace(System.out); // debug inProgressLoadRequestMap.remove(currentLoadRequest.url); continue; diff --git a/src/java/org/xj3d/core/loading/LoaderThreadPool.java b/src/java/org/xj3d/core/loading/LoaderThreadPool.java index 73a80b610e7291d08287fa8e20c9df796e92e4c5..5ec826e74797e3dc2cae4f6faa9499ab4fc3c1ed 100644 --- a/src/java/org/xj3d/core/loading/LoaderThreadPool.java +++ b/src/java/org/xj3d/core/loading/LoaderThreadPool.java @@ -86,9 +86,9 @@ public class LoaderThreadPool { // fetch the system property defining the values Integer prop = AccessController.doPrivileged((PrivilegedAction<Integer>) () -> { int num_processors = Runtime.getRuntime().availableProcessors(); - + DEFAULT_THREAD_COUNT = (num_processors == 1) ? 1 : (num_processors - 1); - + // privileged code goes here, for example: return Integer.getInteger(THREAD_COUNT_PROP, DEFAULT_THREAD_COUNT); }); @@ -99,7 +99,7 @@ public class LoaderThreadPool { if (size != DEFAULT_THREAD_COUNT) System.out.println(THREAD_COUNT_PROP + " set to: " + size); - + loaders = new ContentLoader[size]; for(int i = size; --i >= 0;) @@ -226,13 +226,13 @@ public class LoaderThreadPool { * Ensure all threads are running. */ public void restartThreads() { - + // TODO: Deprecated in JDK16. How to compensate? if (threadGroup.isDestroyed()) { threadGroup = null; threadPool = new LoaderThreadPool(); } - int size = loaders.length; +// int size = loaders.length; for(ContentLoader loader : loaders) { if(!loader.isAlive()) loader = new ContentLoader(threadGroup, pending, inProgress);