<commit_before>Proposal for diploma thesis of Johannes Rudolph

Safer Java Bytecode Generation: A Scala Bytecode Library
========================================================

To compile programs targetting the Java Virtual Machine(JVM), compiler writers
have to emit Java bytecodes, a serialized, binary form of the program. For this
task several libraries exist today. To enforce the well behaviour of the code,
the JVM specification defines several constraints which it imposes upon
bytecode.  The well-formedness of the generated code is then checked at
the time the JVM loads the code. 

Classes being rejected by the classloader are undesirable, so many
bytecode-generating libraries aid the compiler writer by giving him tools to
check if the generated code in spe is valid[2]. Using such a tool errors are
reported at the runtime of the compiler at least.

I propose a Scala library, which - in the best case - doesn't even allow
illegal bytecode sequences to be represented in terms of the library. The
library makes use of Scala's type system to let the Scala compiler reject
illegal combinations of bytecode operations. This is accomplished by encoding
the state of the stack and the local variables as type parameters of an object
representing the current state of the frame. By defining bytecode operations as
transitions between one type of frame and another one can enforce that only
matching operations can be applied to a given frame.

As an application of the library a tool will be developed which compiles an
XPath expression into a corresponding Java class which internally traverses the
DOM of an XML document.

Proposed thesis structure:
 1. Bytecode generation example (XPath or simple expression language)
 2. Summary of "Constraints on Java Virtual Machine Code"[1]
 3. Bytecode DSL
  * The Frame type: Building up stacks of types to represent stack and local variables of a method
  * Encoding of simple bytecode operations
  * Method calls
    * Using scala.reflect.Code to access information about existing methods
    * Forward references for code being defined (not yet sure how to do it)
  * Jumps: encoding of code references
  [* Translating Scala compiler errors into human readable form]
 4. Application: The XPath compiler<commit_msg>small fixes<commit_after>Proposal for diploma thesis of Johannes Rudolph

Safer Java Bytecode Generation: A Scala Bytecode Library
========================================================

To compile programs targetting the Java Virtual Machine(JVM), compiler writers
have to emit Java bytecodes, a serialized, binary form of the program. For this
task several libraries exist today. To enforce the well behaviour of the code,
the JVM specification defines several constraints which it imposes upon
bytecode.  The well-formedness of the generated code is then checked at
the time the JVM loads the code. 

Classes being rejected by the classloader are undesirable, therefore many
bytecode-generating libraries aid the compiler writer by giving him tools to
check if the generated code in spe is valid[2]. Using such a tool errors are
reported at the runtime of the compiler at least.

I propose a Scala library, which - in the best case - doesn't even allow
illegal bytecode sequences to be represented in terms of the library. The
library makes use of Scala's type system to let the Scala compiler reject
illegal combinations of bytecode operations. This is accomplished by encoding
the state of the stack and the local variables as type parameters of an object
representing the current state of the frame. By defining bytecode operations as
transitions between one type of frame and another one can enforce that only
matching operations can be applied to a given frame.

As an application of the library a tool will be developed which compiles an
XPath expression into corresponding Java bytecodes which internally traverse the
DOM of an XML document.

Proposed thesis structure:
 1. Bytecode generation example (XPath or simple expression language)
 2. Summary of "Constraints on Java Virtual Machine Code"[1]
 3. Bytecode DSL
  * The Frame type: Building up stacks of types to represent stack and local variables of a method
  * Encoding of simple bytecode operations
  * Method calls
    * Using scala.reflect.Code to access information about existing methods
    * Forward references for code being defined (not yet sure how to do it)
  * Jumps: encoding of code references
  [* Translating Scala compiler errors into human readable form]
 4. Application: The XPath compiler
{'fraction_non_alphanumeric': 0.05006587615283267, 'fraction_numerical': 0.002635046113306983, 'mean_word_length': 4.700876095118899, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6792076', 'n_tokens_mistral': 1047, 'n_tokens_neox': 994, 'n_words': 677}