This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public long getPrice() { | |
return unsafe.getInt(objectOffset + priceOffset); | |
} | |
public void setPrice(final int price) { | |
unsafe.putInt(objectOffset + priceOffset, price); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
address = unsafe.allocateMemory(TRADES_PER_DAY * UnsafeTrade.getObjectSize()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Constructor<Unsafe> constructor = Unsafe.class.getDeclaredConstructor(); | |
constructor.setAccessible(true); | |
Unsafe unsafe = constructor.newInstance(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Field field = Unsafe.class.getDeclaredField("theUnsafe"); | |
field.setAccessible(true); | |
Unsafe unsafe = (Unsafe) field.get(null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@CallerSensitive | |
public static Unsafe getUnsafe() { | |
Class var0 = Reflection.getCallerClass(); | |
if(!VM.isSystemDomainLoader(var0.getClassLoader())) { | |
throw new SecurityException("Unsafe"); | |
} else { | |
return theUnsafe; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static class UnsafeTrade { | |
private static long offset = 0; | |
private static final long ticketOffset = offset += 0; | |
private static final long amountOffset = offset += 4; | |
private static final long priceOffset = offset += 4; | |
private static final long buyOffset = offset += 4; | |
private static final long objectSize = offset += 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# A fatal error has been detected by the Java Runtime Environment: | |
# | |
# SIGSEGV (0xb) at pc=0xb71a0bde, pid=9350, tid=3066157936 | |
# | |
# JRE version: Java(TM) SE Runtime Environment (8.0_25-b17) (build 1.8.0_25-b17) | |
# Java VM: Java HotSpot(TM) Client VM (25.25-b02 mixed mode linux-x86 ) | |
# Problematic frame: | |
# V [libjvm.so+0x55dbde] Unsafe_SetNativeInt+0x4e | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val test = if (1==1) "a" else "b" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String test = 1 == 1 ? "a" : "b"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String test; | |
if(1 == 1) | |
test = "a"; | |
else | |
test = "b"; |