That depends on what you mean exactly by "allow". All free software licenses (see http://opensource.org/licenses/alphabetical ) will allow such code. What you are doing is typically not considered a modification but rather just using the code/library. If you were to change the code of the original class it would be a modification.
However the nature of GPL is that it is "viral" that means that any application you might be writing that uses GPL code must be licensed under the terms of the GPL or a compatible license (AGPL for example) as well. You can try to lawyer this because of the dynamic linking nature of java, this however is shaky ground and you might want to ask a (few) lawyer(s) about it.
A weaker free software license would allow you to use the code without "infecting" your code with it's license examples of such licenses are Apache Software License, Eclipse Public License, LGPL (as you are not actually modifying code but using the library and subclassing a class you won't even have to redistributed "modified" sourcecode), BSD, MIT, zlib, etc.