def find_class_having_main(self, classes):
for file in classes:
# run javap(1) with type signatures
try:
stdout = subprocess.check_output(
[self.extra_binaries['disassembler'].cmd, '-s', str(file)],
stderr=subprocess.DEVNULL, env=self.compiler.env)
except subprocess.SubprocessError: # noqa
continue
# iterate on lines to find p s v main() signature and then
# its descriptor on the line below; we don't rely on the type
# from the signature, because it could be String[], String... or
# some other syntax I'm not even aware of
lines = iter(stdout.decode().split('\n'))
for line in lines:
line = line.lstrip()
if line.startswith('public static') and 'void main(' in line:
if next(lines).lstrip() == PSVMAIN_DESCRIPTOR:
return file.stem
评论列表
文章目录