com.sun.jdi.VMOutOfMemoryException Java Examples
The following examples show how to use
com.sun.jdi.VMOutOfMemoryException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OomDebugTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unused") // called via reflection private void test2() throws Exception { System.out.println("DEBUG: ------------> Running test2"); try { Field field = targetClass.fieldByName("byteArray"); ArrayType arrType = (ArrayType)field.type(); for (int i = 0; i < 15; i++) { ArrayReference byteArrayVal = arrType.newInstance(3000000); if (byteArrayVal.isCollected()) { System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP."); continue; } invoke("testPrimitive", "([B)V", byteArrayVal); } } catch (VMOutOfMemoryException e) { defaultHandleOOMFailure(e); } }
Example #2
Source File: OomDebugTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unused") // called via reflection private void test2() throws Exception { System.out.println("DEBUG: ------------> Running test2"); try { Field field = targetClass.fieldByName("byteArray"); ArrayType arrType = (ArrayType)field.type(); for (int i = 0; i < 15; i++) { ArrayReference byteArrayVal = arrType.newInstance(3000000); if (byteArrayVal.isCollected()) { System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP."); continue; } invoke("testPrimitive", "([B)V", byteArrayVal); } } catch (VMOutOfMemoryException e) { defaultHandleOOMFailure(e); } }
Example #3
Source File: OomDebugTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unused") // called via reflection private void test2() throws Exception { System.out.println("DEBUG: ------------> Running test2"); try { Field field = targetClass.fieldByName("byteArray"); ArrayType arrType = (ArrayType)field.type(); for (int i = 0; i < 15; i++) { ArrayReference byteArrayVal = arrType.newInstance(3000000); if (byteArrayVal.isCollected()) { System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP."); continue; } invoke("testPrimitive", "([B)V", byteArrayVal); } } catch (VMOutOfMemoryException e) { defaultHandleOOMFailure(e); } }
Example #4
Source File: OomDebugTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unused") // called via reflection private void test2() throws Exception { System.out.println("DEBUG: ------------> Running test2"); try { Field field = targetClass.fieldByName("byteArray"); ArrayType arrType = (ArrayType)field.type(); for (int i = 0; i < 15; i++) { ArrayReference byteArrayVal = arrType.newInstance(3000000); if (byteArrayVal.isCollected()) { System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP."); continue; } invoke("testPrimitive", "([B)V", byteArrayVal); } } catch (VMOutOfMemoryException e) { defaultHandleOOMFailure(e); } }
Example #5
Source File: OomDebugTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unused") // called via reflection private void test2() throws Exception { System.out.println("DEBUG: ------------> Running test2"); try { Field field = targetClass.fieldByName("byteArray"); ArrayType arrType = (ArrayType)field.type(); for (int i = 0; i < 15; i++) { ArrayReference byteArrayVal = arrType.newInstance(3000000); if (byteArrayVal.isCollected()) { System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP."); continue; } invoke("testPrimitive", "([B)V", byteArrayVal); } } catch (VMOutOfMemoryException e) { defaultHandleOOMFailure(e); } }
Example #6
Source File: OomDebugTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unused") // called via reflection private void test2() throws Exception { System.out.println("DEBUG: ------------> Running test2"); try { Field field = targetClass.fieldByName("byteArray"); ArrayType arrType = (ArrayType)field.type(); for (int i = 0; i < 15; i++) { ArrayReference byteArrayVal = arrType.newInstance(3000000); if (byteArrayVal.isCollected()) { System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP."); continue; } invoke("testPrimitive", "([B)V", byteArrayVal); } } catch (VMOutOfMemoryException e) { defaultHandleOOMFailure(e); } }
Example #7
Source File: OomDebugTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unused") // called via reflection private void test2() throws Exception { System.out.println("DEBUG: ------------> Running test2"); try { Field field = targetClass.fieldByName("byteArray"); ArrayType arrType = (ArrayType)field.type(); for (int i = 0; i < 15; i++) { ArrayReference byteArrayVal = arrType.newInstance(3000000); if (byteArrayVal.isCollected()) { System.out.println("DEBUG: Object got GC'ed before we can use it. NO-OP."); continue; } invoke("testPrimitive", "([B)V", byteArrayVal); } } catch (VMOutOfMemoryException e) { defaultHandleOOMFailure(e); } }
Example #8
Source File: OomDebugTest.java From hottub with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unused") // called via reflection private void test2() throws Exception { System.out.println("DEBUG: ------------> Running " + testMethodName); try { Field field = targetClass.fieldByName("byteArray"); ArrayType arrType = (ArrayType)field.type(); for (int i = 0; i < 15; i++) { ArrayReference byteArrayVal = arrType.newInstance(3000000); invoke("testPrimitive", "([B)V", byteArrayVal); } } catch (VMOutOfMemoryException e) { defaultHandleOOMFailure(e); } }
Example #9
Source File: DebuggerChecker.java From netbeans with Apache License 2.0 | 4 votes |
public void reload(Project project, OutputWriter logger, String classname) { // check debugger state DebuggerEngine debuggerEngine = DebuggerManager.getDebuggerManager (). getCurrentEngine (); if (debuggerEngine == null) { logger.println("No debugging sessions was found."); return; } JPDADebugger debugger = debuggerEngine.lookupFirst (null, JPDADebugger.class); if (debugger == null) { logger.println("Current debugger is not JPDA one."); return; } if (!debugger.canFixClasses ()) { logger.println("The debugger does not support Fix action."); return; } if (debugger.getState () == JPDADebugger.STATE_DISCONNECTED) { logger.println("The debugger is not running"); return; } Map<String, byte[]> map = new HashMap<String, byte[]>(); EditorContext editorContext = DebuggerManager. getDebuggerManager ().lookupFirst (null, EditorContext.class); String clazz = classname.replace('.', '/') + ".class"; //NOI18N ProjectSourcesClassPathProvider prv = project.getLookup().lookup(ProjectSourcesClassPathProvider.class); ClassPath[] ccp = prv.getProjectClassPaths(ClassPath.COMPILE); FileObject fo2 = null; for (ClassPath cp : ccp) { fo2 = cp.findResource(clazz); if (fo2 != null) { break; } } if (fo2 != null) { try { String basename = fo2.getName(); for (FileObject classfile : fo2.getParent().getChildren()) { String basename2 = classfile.getName(); if (/*#220338*/!"class".equals(classfile.getExt()) || (!basename2.equals(basename) && !basename2.startsWith(basename + '$'))) { continue; } String url = classToSourceURL(classfile, logger); if (url != null) { editorContext.updateTimeStamp(debugger, url); } map.put(classname + basename2.substring(basename.length()), classfile.asBytes()); } } catch (IOException ex) { ex.printStackTrace (); } } if (map.isEmpty()) { logger.println("No class to reload"); return; } else { StringBuilder sb = new StringBuilder(); sb.append("Classes to reload:\n"); for (String c : map.keySet()) { sb.append(" "); sb.append(c); sb.append("\n"); } logger.println(sb); } String error = null; try { debugger.fixClasses (map); } catch (UnsupportedOperationException uoex) { error = "The virtual machine does not support this operation: "+uoex.getLocalizedMessage(); } catch (NoClassDefFoundError ncdfex) { error = "The bytes don't correspond to the class type (the names don't match): "+ncdfex.getLocalizedMessage(); } catch (VerifyError ver) { error = "A \"verifier\" detects that a class, though well formed, contains an internal inconsistency or security problem: "+ver.getLocalizedMessage(); } catch (UnsupportedClassVersionError ucver) { error = "The major and minor version numbers in bytes are not supported by the VM. "+ucver.getLocalizedMessage(); } catch (ClassFormatError cfer) { error = "The bytes do not represent a valid class. "+cfer.getLocalizedMessage(); LOGGER.log(Level.INFO, error, cfer); //#216376 } catch (ClassCircularityError ccer) { error = "A circularity has been detected while initializing a class: "+ccer.getLocalizedMessage(); } catch (VMOutOfMemoryException oomex) { error = "Out of memory in the target VM has occurred during class reload."; } if (error != null) { logger.println(error); } else { logger.println("Code updated"); } }
Example #10
Source File: JPDAReload.java From netbeans with Apache License 2.0 | 4 votes |
@Override public void execute() throws BuildException { if (logger.isLoggable(Level.FINE)) { logger.fine("JPDAReload.execute(), filesets = "+filesets); } if (filesets.size() == 0) { throw new BuildException ("A nested fileset with class to refresh in VM must be specified."); } // check debugger state DebuggerEngine debuggerEngine = DebuggerManager.getDebuggerManager (). getCurrentEngine (); if (debuggerEngine == null) { throw new BuildException ("No debugging sessions was found."); } JPDADebugger debugger = debuggerEngine.lookupFirst(null, JPDADebugger.class); if (debugger == null) { throw new BuildException("Current debugger is not JPDA one."); } if (!debugger.canFixClasses ()) { throw new BuildException("The debugger does not support Fix action."); } if (debugger.getState () == JPDADebugger.STATE_DISCONNECTED) { throw new BuildException ("The debugger is not running"); } System.out.println ("Classes to be reloaded:"); FileUtils fileUtils = FileUtils.getFileUtils(); Map map = new HashMap (); EditorContext editorContext = DebuggerManager.getDebuggerManager().lookupFirst(null, EditorContext.class); Iterator it = filesets.iterator (); while (it.hasNext ()) { FileSet fs = (FileSet) it.next (); DirectoryScanner ds = fs.getDirectoryScanner (getProject ()); String fileNames[] = ds.getIncludedFiles (); File baseDir = fs.getDir (getProject ()); int i, k = fileNames.length; for (i = 0; i < k; i++) { File f = fileUtils.resolveFile (baseDir, fileNames [i]); if (f != null) { FileObject fo = FileUtil.toFileObject(f); if (fo != null) { try { String url = classToSourceURL (fo); if (url != null) editorContext.updateTimeStamp (debugger, url); InputStream is = fo.getInputStream (); long fileSize = fo.getSize (); byte[] bytecode = new byte [(int) fileSize]; is.read (bytecode); // remove ".class" from and use dots for for separator String className = fileNames [i].substring ( 0, fileNames [i].length () - 6 ).replace (File.separatorChar, '.'); map.put ( className, bytecode ); System.out.println (" " + className); } catch (IOException ex) { ex.printStackTrace (); } } } } } if (logger.isLoggable(Level.FINE)) { logger.fine("Reloaded classes: "+map.keySet()); } if (map.size () == 0) { System.out.println (" No class to reload"); return; } String error = null; try { debugger.fixClasses (map); } catch (UnsupportedOperationException uoex) { error = "The virtual machine does not support this operation: "+uoex.getLocalizedMessage(); } catch (NoClassDefFoundError ncdfex) { error = "The bytes don't correspond to the class type (the names don't match): "+ncdfex.getLocalizedMessage(); } catch (VerifyError ver) { error = "A \"verifier\" detects that a class, though well formed, contains an internal inconsistency or security problem: "+ver.getLocalizedMessage(); } catch (UnsupportedClassVersionError ucver) { error = "The major and minor version numbers in bytes are not supported by the VM. "+ucver.getLocalizedMessage(); } catch (ClassFormatError cfer) { error = "The bytes do not represent a valid class. "+cfer.getLocalizedMessage(); } catch (ClassCircularityError ccer) { error = "A circularity has been detected while initializing a class: "+ccer.getLocalizedMessage(); } catch (VMOutOfMemoryException oomex) { error = "Out of memory in the target VM has occurred during class reload."; } if (error != null) { getProject().log(error, Project.MSG_ERR); throw new BuildException(error); } }