Skip to content

Instantly share code, notes, and snippets.

@alexkasko
alexkasko / LimitedExecutorServiceWrapper.java
Created November 9, 2012 14:08
ExecutorService wrapper, limits max parallel threads
/**
* {@link ExecutorService} wrapper, limit max parallel threads to provided limit.
* May be useful for task with different parrallelism over the same executor.
*
* @author alexkasko
* Date: 7/6/12
*/
public class LimitedExecutorServiceWrapper implements ExecutorService {
private final ExecutorService target;
private final Semaphore semaphore;
public class BeanPropertySqlParameterSourceNotThreadSafeTest {
@Test
public void test() throws InterruptedException {
BeanPropertySqlParameterSource sps = new BeanPropertySqlParameterSource(new ImmutableClass());
Thread[] threads = new Thread[1000];
CountDownLatch latch = new CountDownLatch(1000);
for (int i = 0; i < 1000; i++) {
Thread th = new TestThread(latch, sps);
threads[i] = th;
th.start();
@Test
public void testTcp() throws InterruptedException {
new Thread(new Runnable() {
@Override
public void run() {
try {
ServerSocket ss = new ServerSocket();
ss.bind(new InetSocketAddress(2121));
Socket client = ss.accept();
byte[] data = new byte[200];
@alexkasko
alexkasko / LongPackUtils.java
Created February 16, 2013 18:58
Utility methods to pack long (limited by bits) and int into one long and read them from there
public class LongPackUtils {
public static long pack(long big, int little, int bits) {
assert bits > 32 && bits < 64;
assert big < (1L << bits);
assert little < (1 << (64 - bits));
int ls = bits % 8;
int bm = (1 << ls) - 1;
long res = (big & ~bm) << (64 - bits);
res |= (little & ((1L << (64 - bits)) - 1)) << ls;
res |= big & bm;
@alexkasko
alexkasko / sun.misc.Unsafe.diff
Created March 13, 2013 21:03
Patch to OpenJDK6 sun.misc.Unsafe class that restores additional copyMemory method
diff --git a/jdk/src/share/classes/sun/misc/Unsafe.java b/jdk/src/share/classes/sun/misc/Unsafe.java
index 345f654..5b6b54a 100644
--- a/jdk/src/share/classes/sun/misc/Unsafe.java
+++ b/jdk/src/share/classes/sun/misc/Unsafe.java
@@ -502,11 +502,41 @@ public final class Unsafe {
public native void setMemory(long address, long bytes, byte value);
/**
+ * alexkasko: reverting changes to match jdk7 signature
+ * http://hg.openjdk.java.net/jdk6/jdk6/jdk/diff/39e8fe7a0af1/src/share/classes/sun/misc/Unsafe.java
diff --git a/jni/NativeFormats/fbreader/src/formats/txt/PlainTextFormat.cpp b/jni/NativeFormats/fbreader/src/formats/txt/PlainTextFormat.cpp
index a64e26a..cc4d1d4 100644
--- a/jni/NativeFormats/fbreader/src/formats/txt/PlainTextFormat.cpp
+++ b/jni/NativeFormats/fbreader/src/formats/txt/PlainTextFormat.cpp
@@ -160,14 +160,15 @@ void PlainTextFormatDetector::detect(ZLInputStream &stream, PlainTextFormat &for
}
{
- int breakType = 0;
- breakType |= PlainTextFormat::BREAK_PARAGRAPH_AT_EMPTY_LINE;
@alexkasko
alexkasko / iced_tea_windows_i568_awt.log
Created June 13, 2013 12:22
error building iced tea 1.12.5 on windows i586
>>>Recursively making awt all @ Thu Jun 13 03:32:53 PDT 2013 ...
make[4]: Entering directory `/cygdrive/c/obf/openjdksrc/jdk/make/sun/awt'
rm -f C:/obf/OPENJD~2/build/WINDOW~1/gensrc/sun/awt/windows/awtLocalization.java
# Adding to compile properties list: ../../../src/windows/classes/sun/awt/windows/awtLocalization.properties -> C:/obf/OPENJD~2/build/WINDOW~1/gensrc/sun/awt/windows/awtLocalization.java
/usr/bin/echo -e "-compile ../../../src/windows/classes/sun/awt/windows/awtLocalization.properties C:/obf/OPENJD~2/build/WINDOW~1/gensrc/sun/awt/windows/awtLocalization.java ListResourceBundle" >> C:/obf/OPENJD~2/build/WINDOW~1/tmp/sun/sun.awt/awt/compile_prop_options
rm -f C:/obf/OPENJD~2/build/WINDOW~1/gensrc/sun/awt/windows/awtLocalization_de.java
# Adding to compile properties list: ../../../src/windows/classes/sun/awt/windows/awtLocalization_de.properties -> C:/obf/OPENJD~2/build/WINDOW~1/gensrc/sun/awt/windows/awtLocalization_de.java
/usr/bin/echo -e "-compile ../../../src/windows/classes/sun/awt/windows
@alexkasko
alexkasko / diff.list
Created June 18, 2013 12:58
List of "openjdk" directory files different between icedtea 1.12.5 "make patch" and "make and abort build"
.../test/serviceability/SDTProbesGNULinuxTest.sh | 68 +
.../sun/image/codec/jpeg/ImageFormatException.java | 51 +
.../com/sun/image/codec/jpeg/JPEGCodec.java | 193 +++
.../com/sun/image/codec/jpeg/JPEGDecodeParam.java | 390 +++++
.../com/sun/image/codec/jpeg/JPEGEncodeParam.java | 307 ++++
.../com/sun/image/codec/jpeg/JPEGHuffmanTable.java | 129 ++
.../com/sun/image/codec/jpeg/JPEGImageDecoder.java | 102 ++
.../com/sun/image/codec/jpeg/JPEGImageEncoder.java | 208 +++
.../com/sun/image/codec/jpeg/JPEGQTable.java | 118 ++
.../image/codec/jpeg/TruncatedFileException.java | 92 ++
@alexkasko
alexkasko / make_patch.diff
Created June 18, 2013 13:00
Diff for "openjdk" directory files different between icedtea 1.12.5 "make patch" and "make and abort build"
diff --git a/hotspot/test/serviceability/SDTProbesGNULinuxTest.sh b/hotspot/test/serviceability/SDTProbesGNULinuxTest.sh
new file mode 100644
index 0000000..1fd79d6
--- /dev/null
+++ b/hotspot/test/serviceability/SDTProbesGNULinuxTest.sh
@@ -0,0 +1,68 @@
+#
+# Copyright (c) 2012, Red Hat, Inc.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
@alexkasko
alexkasko / krakatau-jython.diff
Created October 1, 2013 16:40
Changes added to krakatau sources to run them on jython
diff --git a/Krakatau/assembler/assembler.py b/Krakatau/assembler/assembler.py
index a6eec35..a875268 100644
--- a/Krakatau/assembler/assembler.py
+++ b/Krakatau/assembler/assembler.py
@@ -66,7 +66,7 @@ class PoolInfo(object):
self.pool.copyItem(used, index)
_format_ops = collections.defaultdict(tuple)
-_format_ops[''] = instructions.instrs_noarg
+_format_ops['>'] = instructions.instrs_noarg