Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/vm/TruffleVM.java @ 21481:bb51b9a142b3
Enforcing public, one parameter constructor for each TruffleLanguage by annotation processor and required call to super.
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Mon, 25 May 2015 12:26:53 +0200 |
parents | 2dad34a3d7b0 |
children | 3286fb5fea4a b1530a6cce8c |
comparison
equal
deleted
inserted
replaced
21480:c2b006c5e15f | 21481:bb51b9a142b3 |
---|---|
31 import com.oracle.truffle.api.source.Source; | 31 import com.oracle.truffle.api.source.Source; |
32 import java.io.File; | 32 import java.io.File; |
33 import java.io.IOException; | 33 import java.io.IOException; |
34 import java.io.InputStream; | 34 import java.io.InputStream; |
35 import java.io.Reader; | 35 import java.io.Reader; |
36 import java.lang.reflect.Constructor; | |
36 import java.net.URI; | 37 import java.net.URI; |
37 import java.net.URL; | 38 import java.net.URL; |
38 import java.net.URLConnection; | 39 import java.net.URLConnection; |
39 import java.nio.file.Files; | 40 import java.nio.file.Files; |
40 import java.util.ArrayList; | 41 import java.util.ArrayList; |
331 | 332 |
332 TruffleLanguage getImpl() { | 333 TruffleLanguage getImpl() { |
333 if (impl == null) { | 334 if (impl == null) { |
334 String n = props.getProperty("className"); | 335 String n = props.getProperty("className"); |
335 try { | 336 try { |
336 TruffleLanguage lang = (TruffleLanguage) Class.forName(n, true, loader()).newInstance(); | 337 Class<?> langClazz = Class.forName(n, true, loader()); |
337 SPI.attachEnv(TruffleVM.this, lang); | 338 Constructor<?> constructor = langClazz.getConstructor(Env.class); |
338 impl = lang; | 339 impl = SPI.attachEnv(TruffleVM.this, constructor); |
339 } catch (Exception ex) { | 340 } catch (Exception ex) { |
340 throw new IllegalStateException("Cannot initialize " + getName() + " language with implementation " + n, ex); | 341 throw new IllegalStateException("Cannot initialize " + getName() + " language with implementation " + n, ex); |
341 } | 342 } |
342 } | 343 } |
343 return impl; | 344 return impl; |
365 } | 366 } |
366 return null; | 367 return null; |
367 } | 368 } |
368 | 369 |
369 @Override | 370 @Override |
370 public Env attachEnv(TruffleVM vm, TruffleLanguage l) { | 371 public TruffleLanguage attachEnv(TruffleVM vm, Constructor<?> langClazz) { |
371 return super.attachEnv(vm, l); | 372 return super.attachEnv(vm, langClazz); |
372 } | 373 } |
373 | 374 |
374 @Override | 375 @Override |
375 public Object eval(TruffleLanguage l, Source s) throws IOException { | 376 public Object eval(TruffleLanguage l, Source s) throws IOException { |
376 return super.eval(l, s); | 377 return super.eval(l, s); |