René's URL Explorer Experiment


Title: Set Java 8 release compiler option by ryandens · Pull Request #334 · hypertrace/javaagent · GitHub

Open Graph Title: Set Java 8 release compiler option by ryandens · Pull Request #334 · hypertrace/javaagent

X Title: Set Java 8 release compiler option by ryandens · Pull Request #334 · hypertrace/javaagent

Description: Use --release flag to target JDK 8 bytecode compatibility My recent change to capture HTTP requests contained a fascinating bug resulting in the bug-fix not working when running on JVMs <= 1.8 due to a NoSuchMethodError being thrown when this line executes. This was incredibly surprising to me, because the position(int) API exists on Buffer (the superclass of ByteBuffer ) in java 1.8, so why do we have problems here? Confused, I did a quick google search and found an incredibly helpful article right away: ByteBuffer and the Dreaded NoSuchMethodError. The tl;dr of this change is that, the bytecode we produce prior to this change looked like this: BEFORE public static void handleRead(java.nio.ByteBuffer, int, org.hypertrace.agent.core.instrumentation.SpanAndBuffer); descriptor: (Ljava/nio/ByteBuffer;ILorg/hypertrace/agent/core/instrumentation/SpanAndBuffer;)V flags: (0x0009) ACC_PUBLIC, ACC_STATIC Code: stack=3, locals=6, args_size=3 0: iload_1 1: ifgt 5 4: return 5: aload_0 6: aload_0 7: invokevirtual #23 // Method java/nio/ByteBuffer.position:()I 10: iload_1 11: isub 12: invokevirtual #24 // Method java/nio/ByteBuffer.position:(I)Ljava/nio/ByteBuffer; AFTER public static void handleRead(java.nio.ByteBuffer, int, org.hypertrace.agent.core.instrumentation.SpanAndBuffer); descriptor: (Ljava/nio/ByteBuffer;ILorg/hypertrace/agent/core/instrumentation/SpanAndBuffer;)V flags: (0x0009) ACC_PUBLIC, ACC_STATIC Code: stack=3, locals=6, args_size=3 0: iload_1 1: ifgt 5 4: return 5: aload_0 6: aload_0 7: invokevirtual #23 // Method java/nio/ByteBuffer.position:()I 10: iload_1 11: isub 12: invokevirtual #24 // Method java/nio/ByteBuffer.position:(I)Ljava/nio/Buffer; Spot the difference? The bytecode for this snippet is identical, but when compiled without the --release 8, the invokevirtual #24 call refers to a method reference in the constant pool with a signature matching the descriptor Method java/nio/ByteBuffer.position:(I)Ljava/nio/ByteBuffer. However, when we compile it with the --release 8 flag the method reference in the constant pool is Method java/nio/ByteBuffer.position:(I)Ljava/nio/Buffer. This resolves the cross-jre compatibility issue of using the ByteBuffer.position(int) API because Method java/nio/ByteBuffer.position:(I)Ljava/nio/ByteBuffer does not exist on JDK 1.8 or below. Other notes It's worth noting that this has impacted many well-known open source projects. The blog i linked above links to several other projects that encountered this exact issue: Eclipse Jetty Apache Pulsar Eclipse Vert.x Apache Thrift the Yugabyte DB client Debezium (the project the author found the bug on) The author also evaluated other methods of resolving this issue and verifying that it couldn't happen again, and determined the --release flag was the best option: Note that theoretically you could achieve the same effect also when using --source and --target; by means of the --boot-class-path option, you could advise the compiler to use a specific set of bootstrap class files instead of those from the JDK used for compilation. But that’d be quite a bit more cumbersome as it requires you to actually provide the classes of the targeted Java version, whereas --release will make use of the signature data coming with the currently used JDK itself.

Open Graph Description: Use --release flag to target JDK 8 bytecode compatibility My recent change to capture HTTP requests contained a fascinating bug resulting in the bug-fix not working when running on JVMs <= 1.8 d...

X Description: Use --release flag to target JDK 8 bytecode compatibility My recent change to capture HTTP requests contained a fascinating bug resulting in the bug-fix not working when running on JVMs &lt;= 1...

Opengraph URL: https://github.com/hypertrace/javaagent/pull/334

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:36514263-a652-207b-3cda-9a79073e56e2
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id84B2:3A6932:8238E9:B13DB5:6A4DD672
html-safe-nonceb53a1f8ba68a7ee23d404b73142132cb2ffcfe5e8afe321555cdfb5c859d5c80
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEIyOjNBNjkzMjo4MjM4RTk6QjEzREI1OjZBNERENjcyIiwidmlzaXRvcl9pZCI6Ijg2ODA1NDM4NDgwODQ5MTk5MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac21b598207668b924ad5b3d8265ac2cb856c8104c010fb70ee91c6ba32d57be12
hovercard-subject-tagpull_request:688194621
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/hypertrace/javaagent/pull/334/files
twitter:imagehttps://avatars.githubusercontent.com/u/8192732?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/8192732?s=400&v=4
og:image:altUse --release flag to target JDK 8 bytecode compatibility My recent change to capture HTTP requests contained a fascinating bug resulting in the bug-fix not working when running on JVMs <= 1.8 d...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/hypertrace/javaagent git https://github.com/hypertrace/javaagent.git
octolytics-dimension-user_id65374698
octolytics-dimension-user_loginhypertrace
octolytics-dimension-repository_id302314733
octolytics-dimension-repository_nwohypertrace/javaagent
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id302314733
octolytics-dimension-repository_network_root_nwohypertrace/javaagent
turbo-body-classeslogged-out env-production page-responsive
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/hypertrace/javaagent/pull/334/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fhypertrace%2Fjavaagent%2Fpull%2F334%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fhypertrace%2Fjavaagent%2Fpull%2F334%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=hypertrace%2Fjavaagent
Reloadhttps://github.com/hypertrace/javaagent/pull/334/files
Reloadhttps://github.com/hypertrace/javaagent/pull/334/files
Reloadhttps://github.com/hypertrace/javaagent/pull/334/files
Please reload this pagehttps://github.com/hypertrace/javaagent/pull/334/files
hypertrace https://github.com/hypertrace
javaagenthttps://github.com/hypertrace/javaagent
Notifications https://github.com/login?return_to=%2Fhypertrace%2Fjavaagent
Fork 14 https://github.com/login?return_to=%2Fhypertrace%2Fjavaagent
Star 37 https://github.com/login?return_to=%2Fhypertrace%2Fjavaagent
Code https://github.com/hypertrace/javaagent
Issues 35 https://github.com/hypertrace/javaagent/issues
Pull requests 4 https://github.com/hypertrace/javaagent/pulls
Discussions https://github.com/hypertrace/javaagent/discussions
Actions https://github.com/hypertrace/javaagent/actions
Projects https://github.com/hypertrace/javaagent/projects
Security and quality 0 https://github.com/hypertrace/javaagent/security
Insights https://github.com/hypertrace/javaagent/pulse
Code https://github.com/hypertrace/javaagent
Issues https://github.com/hypertrace/javaagent/issues
Pull requests https://github.com/hypertrace/javaagent/pulls
Discussions https://github.com/hypertrace/javaagent/discussions
Actions https://github.com/hypertrace/javaagent/actions
Projects https://github.com/hypertrace/javaagent/projects
Security and quality https://github.com/hypertrace/javaagent/security
Insights https://github.com/hypertrace/javaagent/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fhypertrace%2Fjavaagent%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fhypertrace%2Fjavaagent%2Fissues%2Fnew%2Fchoose
ryandenshttps://github.com/ryandens
mainhttps://github.com/hypertrace/javaagent/tree/main
java-release-targethttps://github.com/hypertrace/javaagent/tree/java-release-target
Conversation 5 https://github.com/hypertrace/javaagent/pull/334
Commits 1 https://github.com/hypertrace/javaagent/pull/334/commits
Checks 0 https://github.com/hypertrace/javaagent/pull/334/checks
Files changed https://github.com/hypertrace/javaagent/pull/334/files
Please reload this pagehttps://github.com/hypertrace/javaagent/pull/334/files
Set Java 8 release compiler option https://github.com/hypertrace/javaagent/pull/334/files#top
Show all changes 1 commit https://github.com/hypertrace/javaagent/pull/334/files
d825728 :wrench: set Java 11 release compiler option ryandens Jul 12, 2021 https://github.com/hypertrace/javaagent/pull/334/commits/d825728eed5300118ed8218964cfc05a07d2ba94
Clear filters https://github.com/hypertrace/javaagent/pull/334/files
Please reload this pagehttps://github.com/hypertrace/javaagent/pull/334/files
Please reload this pagehttps://github.com/hypertrace/javaagent/pull/334/files
build.gradle.ktshttps://github.com/hypertrace/javaagent/pull/334/files#diff-c0dfa6bc7a8685217f70a860145fbdf416d449eaff052fa28352c5cec1a98c06
View file https://github.com/hypertrace/javaagent/blob/d825728eed5300118ed8218964cfc05a07d2ba94/build.gradle.kts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/hypertrace/javaagent/pull/334/{{ revealButtonHref }}
https://github.com/hypertrace/javaagent/pull/334/files#diff-c0dfa6bc7a8685217f70a860145fbdf416d449eaff052fa28352c5cec1a98c06
https://github.com/hypertrace/javaagent/pull/334/files#diff-c0dfa6bc7a8685217f70a860145fbdf416d449eaff052fa28352c5cec1a98c06
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.