--- id: javalang version: "0.13.0" license: unclear license_treatment: permissive maintenance: dormant --- # javalang — Pure Python Java parser and tools License: permissive · Maintenance: dormant · Downloads: 369.8K/mo ## What it is and what it does javalang is a pure Python library that parses Java source code into an abstract syntax tree (AST) you can inspect and traverse. It includes a lexer (tokenizer) and parser targeting Java 8, built from the official Java language specification. You pass a complete Java source file as a string to javalang.parse.parse() and get back a CompilationUnit object—the root of a tree where each node represents a syntactic element (package, class, method, etc.). You can iterate over the tree, filter by node type, and extract metadata like class names, package declarations, and method signatures. The library exposes its components individually: you can tokenize code directly with javalang.tokenizer.tokenize() to get a stream of JavaToken objects with position and value info, or use javalang.parser.Parser directly on a token stream to parse snippets (expressions, type declarations, etc.) rather than full compilation units. It depends only on six for Python 2/3 compatibility, making installation lightweight. However, the project is dormant—last updated in 2020—so it will not track language evolution or receive bug fixes. Use it for: - Extract class and method names from Java source files for documentation or code analysis tools. - Build a Java code search or indexing tool that needs to understand package and type structure. - Analyze Java code for metrics (method count, inheritance depth, etc.) without running a compiler. - Implement a Java code refactoring or transformation tool that needs to parse and manipulate the AST. - Validate or lint Java code snippets in a Python application without invoking javac. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. javalang is a pure Python lexer and parser for Java 8 source code that builds an abstract syntax tree you can traverse to extract information about Java classes, methods, and other language elements. Yes, if you need to parse Java 8 code and can tolerate dormant maintenance. The library is stable, has no known vulnerabilities, installs with minimal friction, and carries a permissive license. It is well-suited for one-off analysis or tooling. Avoid it if you need active maintenance, support for newer language features, or ongoing bug fixes. ## Install pip install javalang uv add javalang poetry add javalang ## Installing javalang Before you install: Installation is straightforward with low friction; the package depends only on six and has wheels for both Python 2 and 3. However, maintenance is dormant—the last release was in 2020 and no commits have landed since 2023-09-17, so bug fixes or compatibility updates are unlikely. License in practice: Licensed under MIT (permissive), so you can use, modify, and distribute javalang freely in both open and closed projects with minimal restrictions. Quickstart: import javalang tree = javalang.parse.parse("package example; class Test {}") print(tree.package.name) print(tree.types[0].name) Verify before relying: - Whether the Java 8 parser handles syntax features beyond Java 8 or only Java 8 constructs. - Performance characteristics when parsing large or complex Java source files. - Compatibility with current Python versions beyond what classifiers declare. ## Package facts - License: not declared (permissive) - Python support: unspecified - Install friction: low - Maintenance: dormant - Downloads: 369.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags java parser python, java source code analysis, java ast tree, java lexer tokenizer, parse java files python, java-parsing, ast-analysis, code-inspection [View on SkillFed](https://skillfed.io/packages/javalang) · [View on PyPI](https://pypi.org/project/javalang/)