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

21
LINES

< > BotCompany Repo | #1008598 // invokeEcj

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4942L/28K).

static S invokeEcj(S options) ctex {
  new StringWriter writer;
  PrintWriter printWriter = new(writer);
  
  File optionsFile = File.createTempFile("javax", "");
  saveTextFile(optionsFile, options);

  S[] args = { "@" + optionsFile.getPath() };
      
  Class ecjClass = javax_loadClass("org.eclipse.jdt.internal.compiler.batch.Main");
  Object main = newInstance(ecjClass, printWriter, printWriter, false);
  call(main, "compile", new Object[]{args});
  int errors = (Int) get(main, "globalErrorsCount");

  S output = str(writer);
  if (errors != 0) {
    print(output);
    throw new JavaCompileException("ECJ returned errors. " + output + "\nOptions: " + options);
  }
  ret output;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008598
Snippet name: invokeEcj
Eternal ID of this version: #1008598/7
Text MD5: 3421745df55be047e834fd58717424d7
Transpilation MD5: 865837e06e7d2da0b7510f6cd3327e78
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-11-01 18:01:42
Source code size: 711 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 529 / 594
Version history: 6 change(s)
Referenced in: [show references]