So the title might be a bit confusing so let me clarify using the following example. There are two classes, class A and class B. Class A is a class that I wrote and it can be found in my project. Class B is in an external library that I have as a dependency on my project. I can reference class B but I can't modify it's source. Now lets say class B has a method. Lets call this method "method()" for demonstration purposes. Is there a way for me to listen to when method() gets called from class A? If so, is it possible to even override the method?
You guys might be saying, "Can't you just let class A extend class B?". Well to answer your question, no. The way in which I will be using this concept, I would need to extend the object, not the class which is not possible (at least I don't think it is).
EDIT:
I'm using Java SE.
---What I'm Trying To Accomplish---
Okay so I make Minecraft server mods (mostly known as Bukkit plugins). In the Bukkit library (a dependency you need to create Bukkit plugins), there is a class called PlayerConnection. Every Player has their own PlayerConnection instance. The instance is stored in the EntityPlayer class in a public field called "playerConnection". PlayerConnection is responsible for sending and receiving packets. I need to be able to receive packets sent from that player without overriding the "playerConnection" field in EntityPlayer. I could create my own PlayerConnection class that extends PlayerConnection and set the playerConnection field to an instance of my custom PlayerConnection class but that would interfere with other plugins that use this same method.