// Code fragment:
//
// ClassLoader classloader = {MainClassName}.class.getClassLoader();
//
final JavaTypeName javaTypeName_ClassLoader = JavaTypeName.make(ClassLoader.class);
final JavaExpression classloaderInit =
new JavaExpression.MethodInvocation.Instance(
new JavaExpression.ClassLiteral(mainClassName),
"getClassLoader",
javaTypeName_ClassLoader,
JavaExpression.MethodInvocation.InvocationType.VIRTUAL);
final JavaExpression.LocalVariable classloaderLocalVar = new JavaExpression.LocalVariable("classloader", javaTypeName_ClassLoader);
final JavaStatement classloaderDecl = new JavaStatement.LocalVariableDeclaration(classloaderLocalVar, classloaderInit);
mainMethod.addStatement(classloaderDecl);
////
/// Generate code to set up the execution context to have access to a standalone-JAR-specific
/// ResourceAccess implementation.
//
// Code fragment:
//
// RTExecutionContext executionContext = new RTExecutionContext(
// new ExecutionContextProperties.Builder().toProperties(),
// new StandaloneRuntimeEnvironment(
// classloader,
// new StandaloneJarResourceAccess(classloader)));
//
final JavaTypeName javaTypeName_ExecutionContextProperties = JavaTypeName.make(ExecutionContextProperties.class);
final JavaTypeName javaTypeName_ResourceAccess = JavaTypeName.make(ResourceAccess.class);
final JavaExpression newRuntimeEnvironment =
new JavaExpression.ClassInstanceCreationExpression(
JavaTypeNames.STANDALONE_RUNTIME_ENVIRONMENT,
new JavaExpression[] {