Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-49770] Use Glob Patterns In Resource Config File #8715

Open
wants to merge 81 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
3eace0b
Make agent print modules and patterns in new format
dnestoro Nov 8, 2023
5acfed3
Add CompressedGlobTrie structure and tests
dnestoro Nov 28, 2023
0df5586
Parse new format in ResourceConfigurationParser
dnestoro Nov 29, 2023
8c10eaf
Fix json printer
dnestoro Nov 30, 2023
15d088b
Initial merge config files solution
dnestoro Nov 30, 2023
58b35c0
Change configuration parser to read globs and load them into trie str…
dnestoro Dec 15, 2023
4441513
Change sorting rules and make function returns all patterns that matc…
dnestoro Jan 23, 2024
94371f1
Update some comments
dnestoro Jan 23, 2024
ecf1687
Remove redudant checks
dnestoro Jan 29, 2024
5dc1225
Add pattern validation mechanism
dnestoro Jan 30, 2024
4816753
Update json schema according to changes introduced in this pull request
dnestoro Jan 31, 2024
3205ae3
Refactor after resolving merge conflicts
dnestoro Feb 6, 2024
8c504e0
Relax pattern validation to allow lambdas and inner classes
dnestoro Feb 7, 2024
a1bb22c
Don't try to convert regexes that contains more than one \Q
dnestoro Feb 7, 2024
87ba4cf
Add licenses for newly added files
dnestoro Feb 7, 2024
3fdcdeb
Basic refactoring
dnestoro Feb 8, 2024
57df56f
Revert addedPatterns list to use compiled patterns instead of strings
dnestoro Feb 9, 2024
5ac29c9
Remove leading slash from glob patterns
dnestoro Feb 9, 2024
56bd95e
Basic refactor
dnestoro Feb 9, 2024
cced80c
Fix style gates
dnestoro Feb 13, 2024
9236f3d
Change parameter name to avoid style gate failures
dnestoro Feb 13, 2024
cf79673
Add util function to concatenate resource name to module
dnestoro Feb 23, 2024
40fa8ab
Reordering actions in ResourcesFeature beforeAnalysis
dnestoro Feb 23, 2024
1b62e47
Check globs in runtime when searching for missing metadata
dnestoro Feb 23, 2024
833e790
Fix style
dnestoro Feb 23, 2024
e6e51bb
Add and update class headers
dnestoro Feb 26, 2024
8d433e4
Revert usage of ignoredResources
dnestoro Feb 26, 2024
3927b70
Make adjustments to pass style gates
dnestoro Feb 27, 2024
acf3011
Add missing , in StarTrieNode header
dnestoro Feb 27, 2024
25cab34
Make addedResources set of Strings
dnestoro Feb 29, 2024
de9ab97
Make unified order of calls in ResourceConfiguration
dnestoro Feb 29, 2024
15862f3
Add missing brackets to if statement
dnestoro Feb 29, 2024
5205cc6
Extract directory name / concatenation to eariler stage
dnestoro Mar 1, 2024
9a07997
Small refactor
dnestoro Mar 1, 2024
3902a99
Update comments, update validation exception and add HOSTED_ONLY anot…
dnestoro Mar 4, 2024
96ab639
Restructure CompressedGlobTrie class
dnestoro Mar 5, 2024
796dbfe
Fix bad title for typeReachable in resource-config-schema
dnestoro Mar 7, 2024
d118f41
Fix substracting just one char from prefix instead of whole matched p…
dnestoro Mar 19, 2024
83d3b92
Use better naming for some variables
dnestoro Mar 20, 2024
2f7ba38
Swap glob and module parameters in addGlob function definition
dnestoro Mar 27, 2024
c92c96a
Remove redudant functions from ResourceEntry record
dnestoro Mar 27, 2024
93a9878
Remove equals function from ConditionalElement record
dnestoro Mar 27, 2024
1ae0ddf
Rename TriConsumer interface to GlobPatternConsumer
dnestoro Mar 27, 2024
c857019
Remove static import of assignResourceToModule function
dnestoro Mar 27, 2024
3df060d
Concat strings using + instead of .concat method
dnestoro Mar 27, 2024
5fece5a
Rename assignResourceToModule to transformToTriePath
dnestoro Mar 27, 2024
01d701f
Change the way transformToTriePath is called
dnestoro Mar 27, 2024
a892263
Add new version of resource-config-schema and revert old one
dnestoro Mar 27, 2024
fc8b5ad
Make TrieNode classes package-private
dnestoro Mar 28, 2024
1ed800c
Lower the scope of methods in GlobTrieNode
dnestoro Mar 29, 2024
cb29ad5
Use char override of indexOf instead of the string variant of this fu…
dnestoro Mar 29, 2024
097ad84
Change comments style
dnestoro Mar 29, 2024
00fa425
Make classifyPatterns returning invalid patterns
dnestoro Mar 29, 2024
deb0a5b
Small style changes
dnestoro Apr 1, 2024
f2078b4
Remove public modifiers from constructors in TrieNode classes
dnestoro Apr 1, 2024
6cd7a3b
Trim List and Map sizes after the building of Trie
dnestoro Apr 2, 2024
83699a6
Refactor classifyPatterns to be more readable
dnestoro Apr 2, 2024
a3a6352
Add few more comments
dnestoro Apr 2, 2024
b729e1a
Revert unnecessary change
dnestoro Apr 8, 2024
eea8f2e
Update headers of changed files
dnestoro Apr 8, 2024
ba1ab5e
Add changelog entry
dnestoro Apr 8, 2024
262a177
Make isSimpleQuotedPattern function more readable
dnestoro Apr 9, 2024
fcc911b
Use Collections.newSetFromMap in all places
dnestoro Apr 9, 2024
4755f28
Remove unnecessary string concatenation
dnestoro Apr 9, 2024
47f4d5e
Fix comment missing punctuation
dnestoro Apr 10, 2024
c8261b4
Add platform dependant line separator
dnestoro Apr 12, 2024
1131b9d
Remove redudant variable
dnestoro Apr 12, 2024
9f35651
Replace usages of plain string wildcards with constants
dnestoro Apr 12, 2024
2b8ca66
Extract counting of stars in a pattern into function
dnestoro Apr 12, 2024
7143e1d
Precompile validation regexes
dnestoro Apr 12, 2024
079b81f
Add comment that explains purpose of SquashedParts record
dnestoro Apr 12, 2024
15b1249
Make SAME_LEVEL_IDENTIFIER visible to tests
dnestoro Apr 12, 2024
772f9c8
Remove directory support
dnestoro Apr 23, 2024
ab9df92
Use MODULE_KEY instead of hardcoded string
dnestoro May 10, 2024
bf0b4b5
Calculate number of chars in string faster
dnestoro May 10, 2024
3e16e76
Use level instead of layer everywhere
dnestoro May 10, 2024
efc7e1f
Use star constant everywhere
dnestoro May 10, 2024
0167958
Introduce GLOB_KEY constant
dnestoro May 10, 2024
851dbd6
Return earlier from pattern validation if pattern is empty
dnestoro May 10, 2024
364d806
Use identical match for adding pattern when additional content is not…
dnestoro May 14, 2024
650e5a1
Add javadoc for CompressedGlobTrei
dnestoro May 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -122,4 +122,4 @@
"type": "object",
"title": "JSON schema for the resource-config that GraalVM Native Image uses",
"description": "Native Image will iterate over all resources and match their relative paths against the Java Regex specified in <includes>. If the path matches the Regex, the resource is included. The <excludes> statement instructs Native Image to omit certain included resources that match the given <pattern>"
}
}
@@ -0,0 +1,160 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/resource-config-schema-v1.1.0.json",
"default": {
"globs": [],
"resources": {},
"bundles": []
},
"properties": {
"globs": {
"default": [],
"items": {
"properties": {
"condition": {
"properties": {
"typeReachable": {
"type": "string",
"title": "Fully qualified class name of the class that must be reachable in order to register glob pattern"
}
},
"required": [
"typeReachable"
],
"additionalProperties": false,
"type": "object"
},
"glob": {
"type": "string",
"title": "Resource matching glob"
},
"module": {
"type": "string",
"title": "Module of resource described with glob"
}
},
"required": ["glob"],
"additionalProperties": false,
"type": "object"
},
"type": "array",
"title": "List of glob patterns that are used to match resources for registration"
},
"resources": {
"properties": {
"includes": {
"default": [],
"items": {
"properties": {
"condition": {
"properties": {
"typeReachable": {
"type": "string",
"title": "Fully qualified class name of the class that must be reachable in order to register resource pattern"
}
},
"required": [
"typeReachable"
],
"additionalProperties": false,
"type": "object"
},
"pattern": {
"type": "string",
"title": "Resource matching pattern"
}
},
"additionalProperties": false,
"type": "object"
},
"type": "array",
"title": "List of included resource patterns"
},
"excludes": {
"default": [],
"items": {
"properties": {
"condition": {
"properties": {
"typeReachable": {
"type": "string",
"title": "Fully qualified class name of the class that must be reachable in order to exclude resource pattern"
}
},
"required": [
"typeReachable"
],
"additionalProperties": false,
"type": "object"
},
"pattern": {
"type": "string",
"title": "Resource matching pattern"
}
},
"additionalProperties": false,
"type": "object"
},
"type": "array",
"title": "List of excluded resource patterns"
}
},
"additionalProperties": false,
"type": "object",
"title": "Set of included and excluded lists of patterns"
},
"bundles": {
"default": [],
"items": {
"properties": {
"condition": {
"properties": {
"typeReachable": {
"type": "string",
"title": "Fully qualified class name of the class that must be reachable in order to register resource bundle"
}
},
"required": [
"typeReachable"
],
"additionalProperties": false,
"type": "object"
},
"name": {
"type": "string",
"title": "Fully qualified name of the resource bundle"
},
"locales": {
"default": [],
"items": {
"type": "string"
},
"type": "array",
"title": "List of locales that should be registered for this resource bundle"
},
"classNames": {
"default": [],
"items": {
"type": "string"
},
"type": "array",
"title": "List of fully qualified classnames of resource bundles that are directly included without performing the lookup by basename and locale."
}
},
"additionalProperties": false,
"type": "object"
},
"type": "array",
"title": "List of resource bundles that should be registered"
}
},
"required": [
"bundles",
"resources",
"globs"
],
"additionalProperties": false,
"type": "object",
"title": "JSON schema for the resource-config that GraalVM Native Image uses",
"description": "Native Image will iterate over all resources and match their relative paths against the Java Regex specified in <includes>. If the path matches the Regex, the resource is included. The <excludes> statement instructs Native Image to omit certain included resources that match the given <pattern>"
}
Expand Up @@ -56,6 +56,8 @@ static RuntimeResourceSupport<ConfigurationCondition> singleton() {

void addResource(Module module, String resourcePath);

void addGlob(C condition, String module, String glob);

void injectResource(Module module, String resourcePath, byte[] resourceContent);

void ignoreResources(C condition, String pattern);
Expand Down
1 change: 1 addition & 0 deletions substratevm/CHANGELOG.md
Expand Up @@ -20,6 +20,7 @@ This changelog summarizes major changes to GraalVM Native Image.
* (GR-52534) Change the digest (used e.g. for symbol names) from SHA-1 encoded as a hex string (40 bytes) to 128-bit Murmur3 as a Base-62 string (22 bytes).
* (GR-52578) Print information about embedded resources into `embedded-resources.json` using the `-H:+GenerateEmbeddedResourcesFile` option.
* (GR-51172) Add support to catch OutOfMemoryError exceptions on native image if there is no memory left.
* (GR-49770) Use glob patterns in resource-config file instead of regexp (native image agent prints entries in glob format)

## GraalVM for JDK 22 (Internal Version 24.0.0)
* (GR-48304) Red Hat added support for the JFR event ThreadAllocationStatistics.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -95,6 +95,11 @@ public void addResources(UnresolvedConfigurationCondition condition, String patt
addedResources.add(pattern);
}

@Override
public void addGlob(UnresolvedConfigurationCondition condition, String module, String glob) {
throw VMError.shouldNotReachHere("Unused function.");
}

@Override
public void addResource(Module module, String resourcePath) {
throw VMError.shouldNotReachHere("Unused function.");
Expand Down