Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1022199 // Call default method by reflection Spike, now works in default lib [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (6065L/43K).

!7

sinterface Bla {
  default S bla() { ret "ok"; }
}

sclass Blubb implements Bla {
}

sclass Overridden implements Bla {
  public S bla() { ret "different!"; }
}

sclass OverriddenSubclass extends Overridden {}

p-exp {
  assertEqualsVerbose("ok", call(new Blubb, "bla"));
  assertEqualsVerbose("different!", call(new Overridden, "bla"));
  assertEqualsVerbose("different!", call(new OverriddenSubclass, "bla"));
}

Author comment

Began life as a copy of #1022197

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

-
Snippet ID: #1022199
Snippet name: Call default method by reflection Spike, now works in default lib [OK]
Eternal ID of this version: #1022199/1
Text MD5: e092494c9dd352621cd4a20bb7dd9ffd
Transpilation MD5: 6f2dd56bcaa9fab61afd6c79b6f4cc79
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-11 10:24:36
Source code size: 436 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 337 / 964
Referenced in: