Programming Java 2026

Материал из Public ATP Wiki
Перейти к навигации Перейти к поиску

О курсе

Команда курса

Преподаватель - Мария Рубаненко

Расписание

с 9 сентября

Лекция - Среда 9:00 - 10:25 Аудитория 705 КПМ

Семинар - Суббота 9:00 - 10:25 Аудитория 705 КПМ

Чат курса

Будет направлен на первом занятии

Course outline:

Block 1: Language Foundations, Syntax, and OOP

Module 1: Introduction to Java, Primitives, and OOP Core

Lecture: How Java works: compilation, bytecode, JRE/JDK, and high-level JVM architecture. Primitive data types, explicit and implicit casting. Control flow statements and loops. Classes, objects, methods, and constructors. The this and static keywords. The four pillars of OOP in practice: encapsulation, inheritance, polymorphism, and abstraction. Access modifiers.

Seminar: +


Module 2: Reference Types, Arrays, Strings, and Exception Handling

Lecture: One-dimensional and multidimensional arrays. Working with strings: String (why is it immutable?), the String Pool, StringBuilder, and StringBuffer. Packages and imports. The exception hierarchy (Throwable, Exception, Error, RuntimeException). Checked vs. Unchecked exceptions. The try-catch-finally blocks, throw, and throws operators. The try-with-resources statement and the AutoCloseable interface.

Seminar: +


Module 3: Java Collections Framework Architecture

Lecture: The Collections hierarchy: List, Set, Queue, and Map. Deep dive under the hood: ArrayList (dynamic resizing) and LinkedList (doubly-linked list). The equals() and hashCode() contract—why it is critical. Mechanics of HashMap and HashSet (buckets, collisions, treeification in Java 8+). TreeSet and TreeMap (Red-Black trees) along with the Comparable and Comparator interfaces.

Seminar: +


Block 2: Hardcore Core Java (Generics, FP, and Memory)

Module 4: Deep Dive into Generics (Type Erasure & PECS)


Lecture: The purpose of Generics. Parameterized classes, interfaces, and methods. How generics work under the hood: Type Erasure and Bridge Methods. Bounded type parameters: extends vs. super. The PECS rule (Producer Extends, Consumer Super). Wildcards in complex class hierarchies. Invariance, covariance, and contravariance.

Seminar: +

Module 5: Functional Interfaces and Stream API


Lecture: Comprehensive breakdown of Functional Programming concepts. Core functional interfaces: Predicate, Consumer, Function, Supplier, and UnaryOperator. Creating custom interfaces with @FunctionalInterface. How lambdas compile: invokedynamic instructions. Method References and Variable Capture. Stream API lifecycle: intermediate vs. terminal operations. Lazy evaluations. Crafting custom Collector implementations.

Seminar: +

Module 6: Concurrency — Part 1: Foundations and Synchronization

Lecture: Understanding Processes and Threads. Thread creation using Thread and Runnable. Thread lifecycle and states (NEW, RUNNABLE, BLOCKED, WAITING, etc.). Common multithreading pitfalls: Race Conditions, Deadlocks, and Livelocks. The synchronized keyword (intrinsic locks, object-level vs. class-level locking). The wait(), notify(), and notifyAll() coordination mechanisms. The volatile keyword and atomicity constraints.

Seminar: +

Module 7: Concurrency — Part 2: Concurrency Utilities and JMM

Lecture: The Java Memory Model (JMM): visibility, instruction reordering, and the happens-before guarantee. Exploring the java.util.concurrent package. Atomic variables (AtomicInteger, AtomicReference). Explicit locks: ReentrantLock and ReadWriteLock. Synchronizers: CountDownLatch, CyclicBarrier, and Semaphore. Thread pools and the ExecutorService. Handling future results with Callable and Future. Thread-safe collections (ConcurrentHashMap, CopyOnWriteArrayList).

Seminar: +

Module 8: Modern JVM Memory Management

Lecture: JVM memory layout (Java 17-25): Heap (Eden, Survivor, Tenured), Metaspace, Code Cache, and Off-Heap (Direct Memory). Stack vs. Heap allocation. Object allocation and garbage collection lifecycles. The evolution of Garbage Collectors: from Serial/Parallel to G1, and modern ultra-low-latency collectors like ZGC (Z Garbage Collector) and Shenandoah (Colored Pointers, Load Barriers).

Seminar: +

🏗 Block 3: Build Automation, Spring Ecosystem, and Data

Module 9: Maven Architecture and Build Automation

Lecture: How Maven operates: build lifecycles, phases, and goals. Anatomy of pom.xml. Dependency management and conflict resolution: Dependency Mediation (nearest-wins rule) and dependency scopes. Working with <dependencyManagement> and build plugins (<plugins>). Designing and configuring multi-module project structures.

Seminar: +


Module 10: Spring Core Under the Hood (IoC, DI & AOP)

Lecture: The philosophy behind Inversion of Control (IoC) and Dependency Injection (DI). The Spring Bean Lifecycle: from BeanDefinition parsing to destruction. Initialization phases, BeanFactoryPostProcessor, and BeanPostProcessor (BPP). Proxying in Spring: JDK Dynamic Proxies vs. CGLIB. Resolving circular dependencies using Spring's three-level cache. Aspects, Advices (Before, After, Around), and Pointcuts. Spring AOP vs. AspectJ.

Seminar: +

Module 11: Spring Data JPA, Hibernate, and Transactions

Lecture: Architectural foundations of JPA and Hibernate. Entity life cycle states (Transient, Persistent, Detached, Removed). Dirty Checking mechanics and the first-level cache. Exposing and solving the N+1 Query problem (JOIN FETCH, EntityGraph). Mapping entity relationships (@OneToMany, @ManyToMany). Internal mechanics of the @Transactional annotation. Transaction isolation levels and propagation behaviors (REQUIRED, REQUIRES).

Seminar: +

Module 12: Spring Web (REST API), Validation, and Spring Boot 3.x


Lecture: Spring Boot philosophy and Auto-configuration using @Conditional annotations. Anatomy of Spring Web: DispatcherServlet, controllers, and request mapping. Designing mature RESTful APIs. Centralized error handling using @ControllerAdvice and @ExceptionHandler. Incoming DTO validation with the Jakarta Validation API. System monitoring with Spring Boot Actuator.

Seminar: +

Block 4: Security, Containerization, and Production Deployment

Module 13: Spring Security, JWT, and Docker Containerization


Lecture: Spring Security architecture: the SecurityFilterChain. The Authentication and Authorization processes. Implementing stateless security architectures using JWT (JSON Web Tokens). Core concepts of Docker containerization: images, containers, layers, volumes, and networking. Writing highly efficient Multi-stage Dockerfiles to strip away build overhead and minimize target production Java runtimes.

Seminar: +

Module 14: CI/CD Pipelines, Nginx, and Production Deployment


Lecture: Continuous Integration and Continuous Delivery (CI/CD) workflows using GitHub Actions or GitLab CI. Automating the pipeline: Maven build ➡ unit/integration testing ➡ Docker image compilation ➡ pushing to a container Registry ➡ remote server deployment. Setting up Nginx as a Reverse Proxy to forward external traffic, load balance, and manage SSL/TLS certificates (via Certbot/Let's Encrypt).

Seminar: +

Practical programming

Block 1: Language Foundations, Syntax, and OOP Module 1: Introduction to Java, Primitives, and OOP Core

Task A: Implement a strictly encapsulated financial accounting system. Instead of using double or float types for monetary values, use BigDecimal. Write internal validation logic, log operations using custom data structures, and implement transaction filtering methods.

Task B: Design a dynamic pricing system. A mutable discount configuration object is passed to the calculation method. Your goal is to protect the internal state of the system from scenarios where an external thread alters the configuration fields midway through the formula execution or passes NaN/Infinity using mathematical workarounds. Additionally, you must eliminate any risk of memory leaks caused by hidden references to parent objects within inner classes.

Module 2: Reference Types, Arrays, Strings, and Exception Handling

Task A: Write a parser for large CSV/JSON logs using pure BufferedReader, strictly enforcing the try-with-resources statement. The program must aggregate error metrics and should never crash when encountering malformed lines; instead, it must gracefully route them to a dedicated repository for corrupted data.

Task B: Optimize the concatenation of millions of strings under a tight memory constraint (e.g., -Xmx32m). A naive implementation using StringBuilder will still trigger an OutOfMemoryError due to continuous reallocation and copying of the internal byte array during expansion. You need to calculate the exact buffer capacity required, implement array pooling (Array Pool), or write directly to a custom byte stream, while ensuring the atomic restoration of the parser's state if a CustomHeavyException occurs.

Module 3: Java Collections Framework Architecture

Task A: Implement a fixed-size LRU (Least Recently Used) cache backed by a LinkedHashMap. Integrate it with the open-source Apache Commons library to automatically track and count element access frequencies.

Task B: Create a data structure where the key in a HashMap is an object containing an internal array or collection. Purposefully break the hashCode() contract to force a severe collision scenario where all elements end up in a single bucket. You are required to force the HashMap to restructure the bucket into a Red-Black tree, but with an added constraint: the key objects must not implement the Comparable interface. Analyze how Java resolves collisions via System.identityHashCode() and its internal class comparison mechanisms, and write a wrapper that guarantees constant lookup time O(1) even under an intentional HashDOS attack.

Block 2: Hardcore Core Java (Generics, Functional Programming, and Memory)

Module 4: Deep Dive into Generics (Type Erasure & PECS)

Task A: Write a generic repository GenericRepository<T, ID> that supports standard CRUD operations. Apply advanced PECS rules (? extends and ? super) to implement methods for bulk saving and data fetching.

Task B: Write a strongly-typed event bus (EventBus). Due to Type Erasure, it is impossible to distinguish List<String> from List<Integer> at runtime using standard approaches. If a component subscribes to List<String> , the bus might inadvertently dispatch a List<Integer> to it, resulting in a runtime ClassCastException crash. You must bypass type erasure by applying the Super Type Tokens pattern to retain full generic type information at runtime and guarantee absolute type safety.

Module 5: Functional Interfaces and Stream API

Task A: Leverage the Stream API to build a counterparty credit scoring engine. Utilize predicate composition (and(), or()) and design a custom Collector capable of calculating the median, mean, and variance of numerical metrics simultaneously in a single pass over the stream.

Task B: Write a heavy data-processing pipeline using parallelStream(), where the tasks are heavily I/O bound. Since parallel streams use the shared ForkJoinPool.commonPool() by default, a naive implementation will choke the entire application's thread pool. You must resolve this issue by forcing the parallel stream to execute inside an isolated, custom ForkJoinPool with a strictly capped thread count, leveraging the unique task-execution mechanics of FJP.

Module 6: Concurrency — Part 1: Foundations and Synchronization

Task A: Implement the Producer-Consumer pattern using low-level wait() / notifyAll() mechanisms on top of a ring array. Integrate proper handling for thread interruption signals via Thread.interrupt().

Task B: Write a high-throughput thread-safe counter. Standard synchronized blocks and even AtomicLong counters will cause severe performance degradation under massive thread contention due to the Cache Line Bouncing effect (threads constantly invalidating each other's CPU cache). You must engineer a solution based on distributed memory cells (similar to the internal design of the open-source LongAdder class), ensuring proper memory alignment (Padding) to prevent False Sharing of cache lines.

Module 7: Concurrency — Part 2: Concurrency Utilities and JMM

Task A: Write a distributed file search engine that coordinates and aggregates results across multiple search phases using an ExecutorService (CompletableFuture) alongside a Phaser or CyclicBarrier.

Task B: Build a thread-safe, non-blocking cache on top of a ConcurrentHashMap. Threads must check for the presence of a key: if missing, they must compute the value (simulating a heavy 5-second network request) and store it in the map. If written naively, 100 threads hitting the same missing key simultaneously will trigger the heavy network call 100 times. You must achieve atomic computation using computeIfAbsent(), with a strict caveat: no heavy blocking operations can be performed directly inside the computation function, as doing so would lock the entire map bucket for other unrelated keys. Elegantly decouple this by combining ConcurrentHashMap and CompletableFuture.

Module 8: Modern JVM Memory Management

Task A: Write a utility that interacts with Off-Heap memory via ByteBuffer.allocateDirect() to cache massive image arrays or binary files completely bypassing the Garbage Collector.

Task B: Intentionally inject a hidden memory leak that standard linters and AI assistants fail to catch, utilizing ThreadLocal variables within an application thread pool. When a web request completes, the thread returns to the pool, but the data inside ThreadLocal remains bound to the thread indefinitely, quietly bleeding the Heap via the ContextClassLoader. You must diagnose this leak using JProfiler or VisualVM, write an integration test that fails when a leak is present, and implement automated cleanup using a custom interceptor.

Block 3: Build Automation, Spring Ecosystem, and Data

Module 9: Maven Architecture and Build Automation

Task A: Construct a multi-module project where one dedicated sub-module generates source code (e.g., generating DTOs from an OpenAPI or Protobuf schema), and other sub-modules reference and consume this generated code. Configure the testing plugins (JaCoCo) with a strict threshold: the build must fail if total test coverage drops below 80%.

Task B: Introduce a third-party open-source library that carries a transitive (hidden) dependency conflicting with Spring Boot. The project will compile perfectly fine but crash at runtime with a LinkageError or ClassCircularityError. You must manually trace the dependency graph using mvn dependency:tree, isolate the conflicting artifact, and resolve it using fine-tuned <exclusions> and <dependencyManagement> blocks. Additionally, write an Enforcer Plugin rule to programmatically block banned transitive dependencies.

Module 10: Spring Core Under the Hood (IoC, DI & AOP)

Task A: Develop a custom BeanPostProcessor that scans for beans decorated with a custom @InjectCrypto annotation. It must automatically initialize cryptographic keys inside them by pulling the payloads from an external, secure vault file.

Task B: Implement a business operation logging system using Spring AOP. The aspect intercepts methods annotated with @LogMe. Within a service, a method public void process() invokes this.internalLog(), which is also marked with @LogMe. Due to Spring's proxy-based architecture, this internal call (self-invocation) bypasses the proxy, meaning the aspect will fail to trigger. You must reproduce this issue and fix it using three advanced techniques of your choice (without duplicating code): using ApplicationContext injection, AopContext.currentProxy(), or by migrating to AspectJ (Compile-Time / Load-Time Weaving).

Module 11: Spring Data JPA, Hibernate, and Transactions

Task A: Model entities for an e-commerce platform. Implement advanced pagination and dynamic multi-criteria order filtering across 10+ concurrent parameters using JPA Specification or Querydsl.

Task B: Implement a bank transfer method decorated with @Transactional. Artificially introduce massive concurrency (e.g., 1,000 parallel requests hitting the same account simultaneously), forcing the system to encounter a DeadlockLoserDataAccessException or a Lost Update anomaly. Your task is to resolve this race condition at the database tier using Optimistic Locking (with explicit handling and retries for ObjectOptimisticLockingFailureException) or Pessimistic Locking (SELECT FOR UPDATE), clearly justifying the performance trade-offs of each approach.

Module 12: Spring Web (REST API), Validation, and Spring Boot 3.x

Task A: Develop a ticket-booking REST API. Implement complex cross-field validation rules (e.g., return dates cannot precede departure dates, and ticket types must match the passenger's age bracket) by writing a custom ConstraintValidator.

Task B: Implement an endpoint for uploading and stream-processing massive binary files exceeding 5 GB. If you attempt to capture the file payload in your controller as a byte[] or via standard MultipartFile bindings, the server will instantly crash with an OutOfMemoryError as it attempts to buffer the entire payload into RAM. You must build a streaming controller that processes incoming data chunks on the fly, pipes the byte stream directly into a persistent storage layer, and broadcasts upload progress in real-time using Server-Sent Events (SSE).

Block 4: Security, Containerization, and Production Deployment

Module 13: Spring Security, JWT, and Docker Containerization

Task A: Build a complete stateless Auth Server using Spring Security. Issue two tokens: a short-lived Access Token (kept in memory) and a long-lived Refresh Token delivered via an HttpOnly cookie with robust XSS/CSRF mitigations.

Task B: Write a Dockerfile to package your Spring Boot application. Running a containerized application under the root user introduces a critical security vulnerability. Furthermore, a naive file structure will cause Docker to re-download all Maven dependencies on every single line-of-code modification. You must write a secure, highly optimized image: enforce multi-stage builds, switch to a non-privileged user (USER appuser), leverage Distroless or Alpine base runtimes, and split your application layout into discrete image layers (dependencies, resources, and class files) to maximize layer caching.

Module 14: CI/CD Pipelines, Nginx, and Production Deployment

Task A: Design a GitHub Actions or GitLab CI pipeline that automatically triggers on every push to the main branch. It must run the test suites, compile the Docker image, scan it for vulnerabilities using an open-source scanner (like Trivy or AquaSecurity), and push the certified image to Docker Hub.

Task B: Deploy your application to a remote cloud server behind an Nginx reverse proxy, ensuring a Zero-Downtime Deployment (Blue-Green or Rolling) strategy. In a standard setup, dropping the old container before launching the new one introduces a ~15-second window where clients experience a 502 Bad Gateway error. You must configure your deployment pipeline, Docker-Compose, and Nginx configurations so that Nginx reroutes external traffic to the new container only after the Spring Boot application boot cycle is fully complete and its Actuator endpoint /actuator/health returns UP. Additionally, ensure the old container executes a Graceful Shutdown to fulfill active user reques