This is first Crazy Code about reflect in java this code when run the out put is
love love love love yes it is due to reflection and java string treat the same value of string also same offset in memory so it replace all try to run
the second code in C++ it print I Love you
love love love love yes it is due to reflection and java string treat the same value of string also same offset in memory so it replace all try to run
import
java.lang.reflect.Field;
public class
TestCodes { /** * @param args the command line arguments */
public static void
main(String[] args) { // TODO code application logic here String str = "hate"; String str2 = "hate"; String str3 ="hate"; String str4 = "hate"; Change(str2); System.out.println(str + " " + str2 +" "+str3+" "+str4); } public static void Change(String original) { try { Field stringValue = String.class.getDeclaredField("value"); stringValue.setAccessible(true); stringValue.set(original, "love".toCharArray()); stringValue.setInt(original, 5); } catch (Exception ex) { // Ignore exceptions } } }
the second code in C++ it print I Love you
#include<stdio.h>
void main()
{
system("color fc");
char *ilu="STILL THINKING HOW I DID IT?\
!r/g.g#i.g/g!j/g.g#i.g/g+g!q0g!mag/h(g!m]g+g!p<g!h`i!l`g!k`g!h\
<g+g!p}g!i}g!i}g!h0g!g]g}g!g}h`g!h}g+g!p<g!h`g}g`g!h}g`h]g`g0g}\
g0g!g}g`g!h<g+g!q]g!n`g!o0g+g!r]g`h!g]g`g0h!g]g}g!g}g!j0g+g!n`g!\
i0g!h}g!g}g!g]g`g0g]g`g0g!h0g(g+g!m}g!g]g!h]g0g`g0g]g!n0g(g+g!m]g\
`g]g}g!g0g!g`h!gag]g!j0g(g+g!p]g0g`g0g\
g.i-g]g(g.g(g!g0g";
//}g]h+g!u]g0g";
for(i=28;l=ilu[i++];)
for(u=(*(ilu+++i)-((1<<6)+(1<<5)+(1<<2)+(1<<1)));u--;)
putchar(!((l-11)^(1<<5))?l-1-(1<<5):l-1);
}
Every week I will posted some crazy or open source code for developers if there are any misunderstand write comment and i will replay
No comments:
Post a Comment