Force proxy with BCEL in java

100 Views Asked by At

Is there some way to replace a call like

Socket s = new Socket(Proxy.NO_PROXY);

with

Socket s = new Socket();

using BCEL because i can't figure out how. I understand it would involve changing the InstructionList but i don't know how to scan for it and i don't know which opcodes to look for.

1

There are 1 best solutions below

1
On

You may get away with much shorter learning curve if you use AspectJ or similar high level tools.

For a low-level bytecode modification you can't get away without learning Java opcodes. A good starting point is JVM Specification. Also, BCEL is not well documented and if you're flexible with choice of low level, I'd suggest using ASM framework. Here is corresponding tutorial on implementing simple bytecode transformation with ASM. It is based on an older ASM version, but the ideas are still the same.