Skip to content

Instantly share code, notes, and snippets.

@ytoshima
ytoshima / sum.java
Created November 18, 2011 16:02
PrintOptoAssembly output example
// -XX::CompileOnly=sum::doit would narrow down the method to compile, but it
// is not used here.
$ ~/jdk1.7.0-b147/fastdebug/bin/java -XX:+PrintOptoAssembly sum
VM option '+PrintOptoAssembly'
{method}
- klass: {other class}
- this oop: 0x911f8110
- method holder: 'sum'
- constants: 0x911f7e10 constant pool [32] for 'sum' cache=0x911f86b0
@ytoshima
ytoshima / classloaders.js
Created February 17, 2016 02:59
OQL samples
//----------------- class looader and loaded classes
select map(heap.objects('java.lang.ClassLoader'), function (it) {
var res = '';
res += "<br/>ClassLoader " + toHtml(it) + "<br/>";
res += listLoadedClasses(it);
return res + "<br>";
function listLoadedClasses(cl) {
var res = "";
if (cl.classes != null) {
if (cl.classes.elementData != null) {
@ytoshima
ytoshima / initial-error-message
Created August 14, 2013 10:32
jdk8 b102 build error on OSX lion
/Users/yoshi/local/openjdk/jdk8-b102-hs25-b45/hotspot/src/os/bsd/vm/attachListener_bsd.cpp: In static member function ‘static void AttachListener::vm_start()’:
/Users/yoshi/local/openjdk/jdk8-b102-hs25-b45/hotspot/src/os/bsd/vm/attachListener_bsd.cpp:455: warning: ‘stat64’ is deprecated (declared at /usr/include/sys/stat.h:466)
/Users/yoshi/local/openjdk/jdk8-b102-hs25-b45/hotspot/src/os/bsd/vm/attachListener_bsd.cpp:455: warning: ‘stat64’ is deprecated (declared at /usr/include/sys/stat.h:466)
make[8]: *** [attachListener_bsd.o] Error 1
make[8]: *** Waiting for unfinished jobs....
make[7]: *** [the_vm] Error 2
make[6]: *** [product] Error 2
make[5]: *** [generic_build2] Error 2
make[4]: *** [product] Error 2
make[3]: *** [all_product_universal] Error 2
import java.io.InputStream;
import java.net.*;
// import java.util.concurrent.Phaser;
// Try mutex/condvar style.
// If it didn't work, try semaphore
// test for JDK-8006395
// Racey test, will not always fail, but if it does then we have a problem.
public class Race15 {
/**
* Small utility script to use JavaFX 2 from scala REPL
* To use ':l fxutil.scala' in REPL.
* Recent java7 JDK contains javafx runtime at $JAVA_HOME/jre/lib/jfxrt.jar
* Scala 2.9 takes -cp or CLASSPATH, so specify the jfxrt.jar path using
* either way.
* Scala 2.10 does not work in the same way. Its startup script passes
* -classpath "", thus -cp does not work. Instead, it has -toolcp option,
* so specify the jfxrt.jar using the option.
*
@ytoshima
ytoshima / DBLEx.scala
Created June 17, 2013 02:56
Berkley-DB Java Edition examples in scala...
package persist.gettingStarted
import com.sleepycat.persist.model.{Entity, PrimaryKey, SecondaryKey}
import com.sleepycat.persist.model.Relationship._
@Entity
class Vendor {
var address: String = _
var bizPhoneNumber: String = _
var city: String = _
@ytoshima
ytoshima / trapex.c
Created May 31, 2013 01:10
A simple program to verify si_code=128 behaviour .
/* Simple test program to verify si_code=SI_KERNEL(128) for address
* above TASK_SIZE64 or TASK_SIZE_MAX (0x800000000000 - 4096 = 0x7ffffffff000)
* See do_page_fault(k).
*/
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
@ytoshima
ytoshima / build.bat
Created March 23, 2013 05:04
ps like command for windows
cl /Zi -D_UNICODE ps2.cpp Psapi.lib
@ytoshima
ytoshima / ck-runtime.c
Created February 21, 2013 09:18
Check whether the specified command line completed in the specified duration in seconds.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <signal.h>
#include <string.h>
@ytoshima
ytoshima / gist:4747954
Created February 10, 2013 01:46
A simple script to show screen resolution
#!/bin/sh
exec ~/local/scala-2.10.0/bin/scala "$0" "$@"
!#
val ge = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment
val mode = ge.getDefaultScreenDevice.getDisplayMode
println("%dx%d".format(mode.getWidth, mode.getHeight))