Home / Function/ forClass() — spring-boot Function Reference

forClass() — spring-boot Function Reference

Architecture documentation for the forClass() function in VersionExtractor.java from the spring-boot codebase.

Function java Metadata VersionDetection calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  f7943596_9447_36bc_3d78_378da5ff732e["forClass()"]
  dd7f425b_83f5_7eee_2e5b_84470e5232a4["customizeCreator()"]
  dd7f425b_83f5_7eee_2e5b_84470e5232a4 -->|calls| f7943596_9447_36bc_3d78_378da5ff732e
  795745ad_6302_82cb_7517_9583cf595b73["getImplementationVersion()"]
  f7943596_9447_36bc_3d78_378da5ff732e -->|calls| 795745ad_6302_82cb_7517_9583cf595b73
  style f7943596_9447_36bc_3d78_378da5ff732e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/util/VersionExtractor.java lines 46–64

	public static @Nullable String forClass(Class<?> cls) {
		String implementationVersion = cls.getPackage().getImplementationVersion();
		if (implementationVersion != null) {
			return implementationVersion;
		}
		URL codeSourceLocation = cls.getProtectionDomain().getCodeSource().getLocation();
		try {
			URLConnection connection = codeSourceLocation.openConnection();
			if (connection instanceof JarURLConnection jarURLConnection) {
				return getImplementationVersion(jarURLConnection.getJarFile());
			}
			try (JarFile jarFile = new JarFile(new File(codeSourceLocation.toURI()))) {
				return getImplementationVersion(jarFile);
			}
		}
		catch (Exception ex) {
			return null;
		}
	}

Domain

Subdomains

Calls

  • getImplementationVersion()

Called By

Frequently Asked Questions

What does forClass() do?
forClass() is a function in the spring-boot codebase.
What does forClass() call?
forClass() calls 1 function(s): getImplementationVersion.
What calls forClass()?
forClass() is called by 1 function(s): customizeCreator.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free