Reflection

What is Reflection? Reflection enables a program to observe and modify its own structure and behavior. t bridges the gap between the base level (the application logic) and the meta level (objects representing the program itself). Core Concepts Introspection: The program can observe its own type information at run time. Intercession (Dynamic Manipulation): The program can modify its own structure and behavior (e.g., adding methods, changing fields). Reflective Code Generation: Creating executable code from data structures at run time. 8.1 Introspection Introspection is the ability to examine the runtime type of an object. The entry point for this in Java is the Class object. ...

December 6, 2025 · Reading Time: 4 minutes ·  By Xuanqiang Angelo Huang

Initialization in Programming Languages

\[...\] This has led to innumerable errors, vulnerabilities, and system crashes.” ~ Tony Hoare 1 The core problem addressed here is Null Safety and how to properly initialize objects to ensure type invariants (specifically non-nullness) hold true. Simple Non-Null Types The goal is to prevent null-dereferencing errors statically. Most of the variables are null, after initialization. Non-Null Types vs. Possibly-Null Types Non-null type T!: Consists of references to T-objects. It cannot hold null. Possibly-null type T?: Consists of references to T-objects plus null. This corresponds to the standard type T in languages like Java, and the most common case among most languages. Type Safety and Invariant Invariant: If the static type of an expression e is a non-null type, then e’s value at runtime must be different from null. Enforcement: We require non-null types for the receiver of each field access, array access, method call, and throw statement. Equivalent to message not understood cited in Typing and Subtyping. Subtyping and Casts The values of T! are a proper subset of T?. ...

December 2, 2025 · Reading Time: 9 minutes ·  By Xuanqiang Angelo Huang

Bytecode Verification

Code in modern days is mobile in the sense that it gets downloaded and executed on the fly very often. In JVM they are usually shipped with: Platform independent code Organized into class files. Class Loaders The class loader is the part of the JVM that takes the bytecode and interprets all the class files to make the program runnable. Security Considerations Requirements for Security Mobile code cannot be trusted Code may not be type safe Code may destroy or modify data Code may expose personal information Code may crash the underlying VM Code may purposefully degrade performance (denial ofservice) This is somewhat similar to the trust relations we explored in Notions of Security. Anyways, since the code is not trusted, we need a way to prove some of its properties. ...

November 15, 2025 · Reading Time: 7 minutes ·  By Xuanqiang Angelo Huang

Typing and Subtyping

We first start with some design goals for the language Language Design Principles Simplicity Syntax and semantics can easily be understood by users and implementers of the language Expressiveness: Language can (easily) express complex processes and structures, conflicting with simplicity. Safety: Language discourages errors and allows errors to be discovered and reported, ideally at compile time Modularity: Language allows modules to be type-checked and compiled separately Performance: Programs written in the language can be executed efficiently Productivity: Language leads to low costs of writing programs like Python. Backwards Compatibility: Newer language versions work and interface with programs in older versions (dependency injection for examples helps for this.) ...

November 11, 2025 · Reading Time: 12 minutes ·  By Xuanqiang Angelo Huang

Object Orientation

Il Tipo di Dato Astratto Introduzione Per questi tipi di dato non ci interessa di sapere cosa ci sia sotto (storato come bit? storato come sabbia boh), ci interessa solamente che abbia quei metodi, che possiamo in un certo senso identificare come la sua capsula, opaca in questo caso. Quando si può andare a modificare solamente attraverso questo metodo potrei dire che sia safe collegato alla Algebra dei tipi, nel senso che vengono soddisfatte sempre le proprietà del tipo. ...

August 28, 2024 · Reading Time: 9 minutes ·  By Xuanqiang Angelo Huang

Polimorfismo

Introduzione Tipi Monomorfici Quando non posso utilizzare un tipo come parametro. Ossia non possiamo definire una funzione generica. Polimorfismo Polimorfismo, come dice il nome, significa avere tante forme, in questo caso tanti tipi. Ma avere tanti tipi non è una cosa ambigua? Questa cosa si risolve solitamente a compile time (facendo checks di sottotipo, oppure dispatch della funzione corretta). A program part is polymorphic if it can be used for objects of several classes ...

August 28, 2024 · Reading Time: 13 minutes ·  By Xuanqiang Angelo Huang

Inheritance

Introduction to Inheritance Difference between Inheritance and Subtyping We say that a subclass is inheritance and subtyping. We have studied subtyping in Typing and Subtyping and it entails mainly two things: Liskov Substitution Polymorphism of the types While inheritance is just the code reuse and specialization. Another example of code reuse can be the “has-a” relation composition, which couples two objects together. With aggregations, we can also see delegation calls, when you have a class, and call a method of that class. ...

October 9, 2025 · Reading Time: 12 minutes ·  By Xuanqiang Angelo Huang

Classi OOP

Introduzione a OOP Per la definizione di classe andare a guardare Object Orientation, però lo ripeto in questa occasione, è solamente un modello su cui andare a costruire degli oggetti. Capisaldi Incapsulazione (con interfaccia, base per la documentazione) Astrazione Ereditarietà Dispatch dinamico Inheritance to avoid code duplication Subtyping to express classification Overriding to specialize methods Dynamic binding to adapt reused algorithms Costruttori Il costruttore è un codice utilizzato per inizializzare correttamente lo stato interno. Le regole sono le stesse dei metodi sovraccaricati (dinamica per la chiamata, statica per il numero dei parametri che prende in input). ...

September 26, 2025 · Reading Time: 6 minutes ·  By Xuanqiang Angelo Huang

Teoria dei Tipi

Introduzione alla Teoria dei Tipi History of Languages Research The root of languages research are in: in logic and computations (even before computers!). Artificial intelligence (Lisp, constrained solvers, the original logical AI we studied in (Russell & Norvig 2009)). Algebra and symbolic reasoning. Definizione di Tipo Un metodo sintattico praticabile per dimostrare l’assenza di determinati comportamenti del programma, fatto classificando le unità sintattiche in base ai tipi di valore che assumono ...

September 28, 2025 · Reading Time: 14 minutes ·  By Xuanqiang Angelo Huang

Semantica di un linguaggio

Vincoli sintattici contestuali Intro: dipendenze da contesto I vincoli sintattici non sono esprimibili tramite BNF perché dipendono dal contesto, mentre le grammatiche libere sono per definizione libere da contesto, vogliamo quindi trovare una soluzione a questo problema. Vengono usati metodi Ad-Hoc nella fase di analisi semantica del programma. Grammatiche dipendenti dal contesto Queste grammatiche sono molto più complicate (e lente) rispetto a quelle libere da contesto, quindi è poco pratico e non utilizzabile (tempo esponenziale, quindi non finisce mai). ...

August 28, 2024 · Reading Time: 9 minutes ·  By Xuanqiang Angelo Huang