import os
import zipfile
# Define the presentation text structures for all 9 slides
SLIDES_DATA = [
{
"is_title": True,
"title": "Automated Legacy Java Library\nDecompilation Pipeline",
"subtitle": "Modernizing Source Artifacts for Java 21+ Environments",
"footer": "Presenter: Systems Architecture Team | Platform: Git Bash / MSYS2 on Windows"
},
{
"title": "The Challenge of Legacy Black Boxes",
"bullets": [
"<b>System Dependencies:</b> Upgrading core infrastructure (like the COMET and CPLS systems) requires modernizing outdated libraries (such as the Java 6 ETSF library).",
"<b>Lost Context:</b> Source repositories for older .jar files are often missing, corrupt, or unmaintained across historical project structures.",
"<b>The Objective:</b> Safely disassemble binary .jar artifacts back into clean, high-concurrency-ready Java 21+ source code structures without introducing structural regression."
]
},
{
"title": "Pipeline Architecture Blueprint",
"bullets": [
"<b>1. Version Control Audit:</b> Peeks inside bytecode headers to identify compliance states before processing.",
"<b>2. Auto-Discovery Engine:</b> Dynamically maps the local filesystem to locate the IDE decompiler runtime.",
"<b>3. Fernflower Decompilation:</b> Disassembles compiled binary classes into highly structured source code.",
"<b>4. Extraction & Housekeeping:</b> Unpacks the generated archives and automatically drops intermediate artifacts."
]
},
{
"title": "Phase 1: Version Control Audit",
"bullets": [
"<b>Source Inspection via 'javap':</b> The script targets the first .class file inside the archive and extracts the binary major version header directly from the bytecode.",
"<b>Dynamic Matrix Mapping:</b> Maps internal bytecode numbers to human-readable names (e.g., major version 50 -> Java 6; 65 -> Java 21).",
"<b>Target Runtime Verification:</b> Queries the discovered IntelliJ Java binary via 'java -version' to ensure destination alignment.",
"<b>Deterministic Logging:</b> Outputs a dedicated [VERSION CONTROL] console block detailing the exact transition path before processing."
]
},
{
"title": "Phase 2: Dynamic Environment Discovery",
"bullets": [
"<b>The Fragility Problem:</b> Hardcoding specific IDE versions (e.g., 'IntelliJ IDEA 2024.3.3') breaks when software updates patch or push paths forward.",
"<b>The Automated Discovery Solution:</b> The script dynamically scans standard corporate installation spaces (C:/Program Files/JetBrains and local AppData).",
"<b>Smart Selection Matrix:</b> Employs an alphanumeric reverse sort ('sort -r') to guarantee that the newest available IDE version and runtime engine are utilized automatically.",
"<b>Fail-Safe Containment:</b> Gracefully interrupts execution with a unique exit code if critical binaries (java.exe or java-decompiler.jar) cannot be resolved."
]
},
{
"title": "Phase 3: Decompilation Execution",
"bullets": [
"<b>Target Directory Enforcement:</b> Checks for the presence of the output folder, instantly spinning up the destination directories via 'mkdir -p' if they do not exist.",
"<b>Absolute Path Mapping ('realpath'):</b> Upgrades input strings to fully qualified filesystem paths to prevent context loss during terminal directory switching.",
"<b>Preserving Type Signatures:</b> Applies the critical generic signature flag (-dgs=true) to preserve advanced structural syntax patterns during decompilation."
]
},
{
"title": "Phase 4: Extraction & Validation",
"bullets": [
"<b>Unpacking the Payload:</b> The Fernflower engine packages its results as a nested .jar file inside your destination folder.",
"<b>Native Unpacking:</b> Uses the JDK utility ('jar -xvf') to extract the structural directories cleanly into the local folder context.",
"<b>Automated Housekeeping:</b> Automatically removes the duplicate intermediate archive file to prevent build-path conflicts or git history clutter.",
"<b>Deterministic Inventory Report:</b> Runs a localized filesystem discovery ('find . -type f') to output a scannable inventory summary of all reconstructed files."
]
},
{
"title": "Built-In Resiliency Matrix",
"bullets": [
"<b>Strict Error Containment ('set -eo pipefail'):</b> Ensures that if any individual command or sub-pipe breaks, execution halts instantly instead of continuing blindly down the line.",
"<b>Context Traps ('trap cleanup_on_err EXIT'):</b> Captures the exact line number and failing command, outputting a highly readable troubleshooting message upon an unexpected crash.",
"<b>Idempotent Behavior:</b> Overwrites older directory traces cleanly on retry without interactive human prompts, making the script fully compatible with automated CI/CD integration pipelines."
]
},
{
"title": "Execution Walkthrough & Console Output",
"is_terminal": True,
"console": (
"$ ./decompile_lib.sh ../etsf-1.0_A20.jar lib\n"
"[INFO] Locating IntelliJ installation environment...\n"
"[INFO] Found Runtime: /c/Program Files/JetBrains/IntelliJ IDEA 2026.1/jbr/bin/java.exe\n"
"------------------------------------------------------------\n"
"[VERSION CONTROL] Pipeline Architecture Mapping:\n"
"[VERSION CONTROL] >> SOURCE bytecode format: Java 6\n"
"[VERSION CONTROL] >> TARGET decompiler runtime: Java 21.0.2\n"
"------------------------------------------------------------\n"
"[INFO] Destination folder 'lib' does not exist. Creating it now...\n"
"[INFO] Executing ConsoleDecompiler against etsf-1.0_A20.jar...\n"
"[INFO] Extracting generated source archive inside target folder...\n"
" extracted: com/etsf/core/Parser.java\n"
" extracted: com/etsf/core/Validator.java\n"
"[INFO] --- Disassembled File Inventory Summary ---\n"
"./com/etsf/core/Parser.java\n"
"./com/etsf/core/Validator.java\n"
"[INFO] Decompilation pipeline successfully completed."
]
}
]
def build_slide_xml(slide_idx, data):
"""Generates the open XML schema layout text string for a slide."""
# Common header mapping definitions
xml = (
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'
'<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" '
'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" '
'xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">\n'
'<p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>'
'<p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>'
)
if data.get("is_title"):
# Layout for Title Slide (Large center title text block)
xml += (
f'<p:sp><p:nvSpPr><p:cNvPr id="{slide_idx}1" name="Title"/><p:cNvSpPr><p:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr/></p:nvSpPr>'
'<p:spPr><a:xfrm><a:off x="914400" y="2000000"/><a:ext cx="10363200" cy="2500000"/></a:xfrm></p:spPr>'
'<p:txBody><a:bodyPr/><a:lstStyle/><a:p>'
f'<a:r><a:rPr sz="4000" b="1"><a:solidFill><a:srgbClr val="0C2340"/></a:solidFill></a:rPr><a:t>{data["title"]}</a:t></a:r>'
'</a:p><a:p><a:pPr><a:lnSpc><a:spcPct val="150000"/></a:lnSpc></a:pPr></a:p>'
'<a:p>'
f'<a:r><a:rPr sz="2000"><a:solidFill><a:srgbClr val="009698"/></a:solidFill></a:rPr><a:t>{data["subtitle"]}</a:t></a:r>'
'</a:p></p:txBody></p:sp>'
f'<p:sp><p:nvSpPr><p:cNvPr id="{slide_idx}2" name="Footer"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>'
'<p:spPr><a:xfrm><a:off x="914400" y="6200000"/><a:ext cx="10363200" cy="500000"/></a:xfrm></p:spPr>'
'<p:txBody><a:bodyPr/><a:lstStyle/><a:p>'
f'<a:r><a:rPr sz="1200"><a:solidFill><a:srgbClr val="555555"/></a:solidFill></a:rPr><a:t>{data["footer"]}</a:t></a:r>'
'</a:p></p:txBody></p:sp>'
)
elif data.get("is_terminal"):
# Layout for Slide 9 (Terminal background and simulation code)
xml += (
f'<p:sp><p:nvSpPr><p:cNvPr id="{slide_idx}1" name="Title"/><p:cNvSpPr><p:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr/></p:nvSpPr>'
'<p:spPr><a:xfrm><a:off x="711200" y="400000"/><a:ext cx="10668000" cy="800000"/></a:xfrm></p:spPr>'
'<p:txBody><a:bodyPr/><a:lstStyle/><a:p>'
f'<a:r><a:rPr sz="3200" b="1"><a:solidFill><a:srgbClr val="0C2340"/></a:srgbClr></a:solidFill></a:rPr><a:t>{data["title"]}</a:t></a:r>'
'</a:p></p:txBody></p:sp>'
# Dark box background
f'<p:sp><p:nvSpPr><p:cNvPr id="{slide_idx}2" name="TerminalBG"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>'
'<p:spPr><a:xfrm><a:off x="711200" y="1500000"/><a:ext cx="10668000" cy="5200000"/></a:xfrm></p:spPr>'
'<p:txBody><a:bodyPr><a:solidFill><a:srgbClr val="1E1E1E"/></a:solidFill></a:bodyPr><a:lstStyle/>'
)
for line in data["console"].split("\n"):
# Sanitize XML tags
clean_line = line.replace("&", "&").replace("<", "<").replace(">", ">")
color = "00FF00" if "[VERSION CONTROL]" in line or ">>" in line else "FFFFFF"
if line.startswith("$"): color = "FFFF00"
xml += f'<a:p><a:r><a:rPr sz="1100" typeface="Consolas"><a:solidFill><a:srgbClr val="{color}"/></a:solidFill></a:rPr><a:t>{clean_line}</a:t></a:r></a:p>'
xml += '</p:txBody></p:sp>'
else:
# Layout for Standard Content Slides (Title + Bullets)
xml += (
f'<p:sp><p:nvSpPr><p:cNvPr id="{slide_idx}1" name="Title"/><p:cNvSpPr><p:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr/></p:nvSpPr>'
'<p:spPr><a:xfrm><a:off x="711200" y="500000"/><a:ext cx="10668000" cy="1000000"/></a:xfrm></p:spPr>'
'<p:txBody><a:bodyPr/><a:lstStyle/><a:p>'
f'<a:r><a:rPr sz="3200" b="1"><a:solidFill><a:srgbClr val="0C2340"/></a:srgbClr></a:solidFill></a:rPr><a:t>{data["title"]}</a:t></a:r>'
'</a:p></p:txBody></p:sp>'
f'<p:sp><p:nvSpPr><p:cNvPr id="{slide_idx}2" name="Content"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>'
'<p:spPr><a:xfrm><a:off x="711200" y="1800000"/><a:ext cx="10668000" cy="5000000"/></a:xfrm></p:spPr>'
'<p:txBody><a:bodyPr/><a:lstStyle/>'
)
for bullet in data["bullets"]:
xml += '<a:p><a:pPr marL="457200" indent="-457200"><a:buNone/></p:pPr>' # Standard bullet offset padding
if "</b>" in bullet:
parts = bullet.split("</b>")
bold_txt = parts[0].replace("<b>", "").replace("&", "&").replace("<", "<").replace(">", ">")
norm_txt = parts[1].replace("&", "&").replace("<", "<").replace(">", ">")
xml += f'<a:r><a:rPr sz="1600" b="1"><a:solidFill><a:srgbClr val="009698"/></a:solidFill></a:rPr><a:t>{bold_txt}</a:t></a:r>'
xml += f'<a:r><a:rPr sz="1600"><a:solidFill><a:srgbClr val="282828"/></a:solidFill></a:rPr><a:t>{norm_txt}</a:t></a:r>'
else:
clean_bullet = bullet.replace("&", "&").replace("<", "<").replace(">", ">")
xml += f'<a:r><a:rPr sz="1600"><a:solidFill><a:srgbClr val="282828"/></a:solidFill></a:rPr><a:t>{clean_bullet}</a:t></a:r>'
xml += '</a:p><a:p><a:pPr><a:lnSpc><a:spcPct val="120000"/></a:lnSpc></a:pPr></a:p>'
xml += '</p:txBody></p:sp>'
xml += '</p:spTree></p:cSld></p:sld>'
return xml
def create_presentation():
"""Generates structural files mapping required Open XML format criteria."""
filename = "Java_Decompilation_Pipeline.pptx"
# 1. Base Core Presentation Mapping configuration
pres_xml = (
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'
'<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" '
'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" '
'xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">\n'
'<p:sldIdLst>\n'
)
for i in range(len(SLIDES_DATA)):
pres_xml += f' <p:sldId id="{256 + i}" r:id="rId{i+1}"/>\n'
# Configured explicitly for 16:9 widescreen output tracking sizes
pres_xml += '</p:sldIdLst>\n<p:sldSz cx="12192000" cy="6858000"/>\n<p:notesSz cx="6858000" cy="9144000"/>\n</p:presentation>'
# 2. Structural Relationship Configurations
rels_xml = (
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'
'<Relationships xmlns="http://schemas.openxmlformats.org/relationships">\n'
)
for i in range(len(SLIDES_DATA)):
rels_xml += f' <Relationship id="rId{i+1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="slides/slide{i+1}.xml"/>\n'
rels_xml += '</Relationships>'
# 3. Content Type Definitions Mapping
content_types_xml = (
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'
'<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">\n'
' <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>\n'
' <Default Extension="xml" ContentType="application/xml"/>\n'
' <Override PartName="/ppt/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/>\n'
)
for i in range(len(SLIDES_DATA)):
content_types_xml += f' <Override PartName="/ppt/slides/slide{i+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>\n'
content_types_xml += '</Types>'
# Write structural files directly into a zipped container file stream
with zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) as pptx:
pptx.writestr('ppt/presentation.xml', pres_xml)
pptx.writestr('ppt/_rels/presentation.xml.rels', rels_xml)
pptx.writestr('[Content_Types].xml', content_types_xml)
# Write individual Slide Components
for idx, slide_data in enumerate(SLIDES_DATA):
slide_xml_content = build_slide_xml(idx + 1, slide_data)
pptx.writestr(f'ppt/slides/slide{idx+1}.xml', slide_xml_content)
print(f"Successfully generated pure PowerPoint asset: '{filename}' without any pip dependencies.")
if __name__ == "__main__":
create_presentation()
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)