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).

1  
static S invokeEcj(S options) ctex {
2  
  new StringWriter writer;
3  
  PrintWriter printWriter = new(writer);
4  
  
5  
  File optionsFile = File.createTempFile("javax", "");
6  
  saveTextFile(optionsFile, options);
7  
8  
  S[] args = { "@" + optionsFile.getPath() };
9  
      
10  
  Class ecjClass = javax_loadClass("org.eclipse.jdt.internal.compiler.batch.Main");
11  
  Object main = newInstance(ecjClass, printWriter, printWriter, false);
12  
  call(main, "compile", new Object[]{args});
13  
  int errors = (Int) get(main, "globalErrorsCount");
14  
15  
  S output = str(writer);
16  
  if (errors != 0) {
17  
    print(output);
18  
    throw new JavaCompileException("ECJ returned errors. " + output + "\nOptions: " + options);
19  
  }
20  
  ret output;
21  
}

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: 612 / 697
Version history: 6 change(s)
Referenced in: [show references]