Created
June 8, 2014 02:45
-
-
Save uemuraj/d4a993e70f2e37df5920 to your computer and use it in GitHub Desktop.
Java のクラスを拡張する場合。元のクラスのインスタンスを参照するには、この書き方しかないのかなあ...
This file contains 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
var File = Java.type("java.io.File"); | |
function extendFile(spec) { | |
var ExtendFile = Java.extend(File); | |
var file = new ExtendFile(spec) { | |
toPath: function() { | |
return java.nio.file.Paths.get(Java.super(file).toURI()); | |
} | |
} | |
return file; | |
} | |
var test = extendFile('test'); | |
print(); | |
print(test.toURL().class); | |
print(test.toURL()); | |
print(); | |
print(test.toURI().class); | |
print(test.toURI()); | |
print(); | |
print(test.toPath().class); | |
print(test.toPath()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment