├── .gitignore ├── LICENSE ├── README.md ├── docs ├── .DS_Store ├── index.html └── style.css ├── java-dangling-pointer-attempt ├── .gitattributes ├── .gitignore ├── app │ ├── bin │ │ ├── main │ │ │ └── dangling │ │ │ │ └── pointer │ │ │ │ └── App.class │ │ └── test │ │ │ └── dangling │ │ │ └── pointer │ │ │ └── AppTest.class │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ └── dangling │ │ │ └── pointer │ │ │ └── App.java │ │ └── test │ │ └── java │ │ └── dangling │ │ └── pointer │ │ └── AppTest.java ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle.kts ├── java-deadlock ├── .gitattributes ├── .gitignore ├── .vscode │ └── settings.json ├── app │ ├── bin │ │ ├── main │ │ │ └── jav │ │ │ │ └── deadlock │ │ │ │ ├── App$1.class │ │ │ │ ├── App$2.class │ │ │ │ └── App.class │ │ └── test │ │ │ └── jav │ │ │ └── deadlock │ │ │ └── AppTest.class │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── jav │ │ │ └── deadlock │ │ │ └── App.java │ │ └── test │ │ └── java │ │ └── jav │ │ └── deadlock │ │ └── AppTest.java ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── java-mpmc-sample ├── .gitattributes ├── .gitignore ├── .vscode │ └── settings.json ├── app │ ├── bin │ │ ├── main │ │ │ └── jav │ │ │ │ └── mpmc │ │ │ │ └── sample │ │ │ │ └── App.class │ │ └── test │ │ │ └── jav │ │ │ └── mpmc │ │ │ └── sample │ │ │ └── AppTest.class │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── jav │ │ │ └── mpmc │ │ │ └── sample │ │ │ └── App.java │ │ └── test │ │ └── java │ │ └── jav │ │ └── mpmc │ │ └── sample │ │ └── AppTest.java ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── java-null-pointer ├── .gitattributes ├── .gitignore ├── .vscode │ └── settings.json ├── app │ ├── bin │ │ ├── main │ │ │ └── javanullpointer │ │ │ │ └── App.class │ │ └── test │ │ │ └── javanullpointer │ │ │ └── AppTest.class │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── javanullpointer │ │ │ └── App.java │ │ └── test │ │ └── java │ │ └── javanullpointer │ │ └── AppTest.java ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── rust-actix-hello-world ├── .gitignore ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs ├── rust-dangling-pointer-attempt ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs ├── rust-deadlock ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs ├── rust-mpmc-sample ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs ├── rust-mpsc-sample ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs ├── rust-null-pointer ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs └── rust-ref-cell-crash ├── Cargo.lock ├── Cargo.toml └── src └── main.rs /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # Ignore Gradle project-specific cache directory 4 | .gradle 5 | 6 | # Ignore Gradle build output directory 7 | build 8 | 9 | # Ignore rust build directory 10 | target 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Security Union 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rust vs Java 2 | 3 | ![thumbnail5](https://user-images.githubusercontent.com/1176339/210205441-9a32c8f6-241a-4cbf-bd4d-e1145754c3f6.png) 4 | 5 | Rust and Java are two of the most popular programming languages, but which one is best for your next project? 6 | 7 | ## YouTube Video 8 | 9 | https://youtu.be/-JwgfNGx_V8?t=332 10 | 11 | ## Cheatsheet 12 | 13 | I put together a cheatsheet to answer this: 14 | https://security-union.github.io/rust-vs-java/ 15 | -------------------------------------------------------------------------------- /docs/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/docs/.DS_Store -------------------------------------------------------------------------------- /docs/style.css: -------------------------------------------------------------------------------- 1 | /* latin */ 2 | @font-face { 3 | font-family: 'Consolas'; 4 | font-style: normal; 5 | font-weight: 400; 6 | src: url(https://fonts.gstatic.com/l/font?kit=X7nm4bA-A_-9jbjWaza9xMnLGADx&skey=3d1eb1871fcc58a1&v=v19) format('woff2'); 7 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; 8 | } 9 | /* cyrillic-ext */ 10 | @font-face { 11 | font-family: 'Open Sans'; 12 | font-style: normal; 13 | font-weight: 400; 14 | font-stretch: 100%; 15 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSKmu0SC55K5gw.woff2) format('woff2'); 16 | unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; 17 | } 18 | /* cyrillic */ 19 | @font-face { 20 | font-family: 'Open Sans'; 21 | font-style: normal; 22 | font-weight: 400; 23 | font-stretch: 100%; 24 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSumu0SC55K5gw.woff2) format('woff2'); 25 | unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 26 | } 27 | /* greek-ext */ 28 | @font-face { 29 | font-family: 'Open Sans'; 30 | font-style: normal; 31 | font-weight: 400; 32 | font-stretch: 100%; 33 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSOmu0SC55K5gw.woff2) format('woff2'); 34 | unicode-range: U+1F00-1FFF; 35 | } 36 | /* greek */ 37 | @font-face { 38 | font-family: 'Open Sans'; 39 | font-style: normal; 40 | font-weight: 400; 41 | font-stretch: 100%; 42 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSymu0SC55K5gw.woff2) format('woff2'); 43 | unicode-range: U+0370-03FF; 44 | } 45 | /* hebrew */ 46 | @font-face { 47 | font-family: 'Open Sans'; 48 | font-style: normal; 49 | font-weight: 400; 50 | font-stretch: 100%; 51 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTS2mu0SC55K5gw.woff2) format('woff2'); 52 | unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; 53 | } 54 | /* vietnamese */ 55 | @font-face { 56 | font-family: 'Open Sans'; 57 | font-style: normal; 58 | font-weight: 400; 59 | font-stretch: 100%; 60 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSCmu0SC55K5gw.woff2) format('woff2'); 61 | unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB; 62 | } 63 | /* latin-ext */ 64 | @font-face { 65 | font-family: 'Open Sans'; 66 | font-style: normal; 67 | font-weight: 400; 68 | font-stretch: 100%; 69 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSGmu0SC55K5gw.woff2) format('woff2'); 70 | unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; 71 | } 72 | /* latin */ 73 | @font-face { 74 | font-family: 'Open Sans'; 75 | font-style: normal; 76 | font-weight: 400; 77 | font-stretch: 100%; 78 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTS-mu0SC55I.woff2) format('woff2'); 79 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; 80 | } 81 | /* cyrillic-ext */ 82 | @font-face { 83 | font-family: 'Open Sans'; 84 | font-style: normal; 85 | font-weight: 700; 86 | font-stretch: 100%; 87 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSKmu0SC55K5gw.woff2) format('woff2'); 88 | unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; 89 | } 90 | /* cyrillic */ 91 | @font-face { 92 | font-family: 'Open Sans'; 93 | font-style: normal; 94 | font-weight: 700; 95 | font-stretch: 100%; 96 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSumu0SC55K5gw.woff2) format('woff2'); 97 | unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 98 | } 99 | /* greek-ext */ 100 | @font-face { 101 | font-family: 'Open Sans'; 102 | font-style: normal; 103 | font-weight: 700; 104 | font-stretch: 100%; 105 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSOmu0SC55K5gw.woff2) format('woff2'); 106 | unicode-range: U+1F00-1FFF; 107 | } 108 | /* greek */ 109 | @font-face { 110 | font-family: 'Open Sans'; 111 | font-style: normal; 112 | font-weight: 700; 113 | font-stretch: 100%; 114 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSymu0SC55K5gw.woff2) format('woff2'); 115 | unicode-range: U+0370-03FF; 116 | } 117 | /* hebrew */ 118 | @font-face { 119 | font-family: 'Open Sans'; 120 | font-style: normal; 121 | font-weight: 700; 122 | font-stretch: 100%; 123 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTS2mu0SC55K5gw.woff2) format('woff2'); 124 | unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; 125 | } 126 | /* vietnamese */ 127 | @font-face { 128 | font-family: 'Open Sans'; 129 | font-style: normal; 130 | font-weight: 700; 131 | font-stretch: 100%; 132 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSCmu0SC55K5gw.woff2) format('woff2'); 133 | unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB; 134 | } 135 | /* latin-ext */ 136 | @font-face { 137 | font-family: 'Open Sans'; 138 | font-style: normal; 139 | font-weight: 700; 140 | font-stretch: 100%; 141 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSGmu0SC55K5gw.woff2) format('woff2'); 142 | unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; 143 | } 144 | /* latin */ 145 | @font-face { 146 | font-family: 'Open Sans'; 147 | font-style: normal; 148 | font-weight: 700; 149 | font-stretch: 100%; 150 | src: url(https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTS-mu0SC55I.woff2) format('woff2'); 151 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; 152 | } 153 | /* cyrillic-ext */ 154 | @font-face { 155 | font-family: 'Roboto'; 156 | font-style: normal; 157 | font-weight: 400; 158 | src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu72xKKTU1Kvnz.woff2) format('woff2'); 159 | unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; 160 | } 161 | /* cyrillic */ 162 | @font-face { 163 | font-family: 'Roboto'; 164 | font-style: normal; 165 | font-weight: 400; 166 | src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu5mxKKTU1Kvnz.woff2) format('woff2'); 167 | unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; 168 | } 169 | /* greek-ext */ 170 | @font-face { 171 | font-family: 'Roboto'; 172 | font-style: normal; 173 | font-weight: 400; 174 | src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu7mxKKTU1Kvnz.woff2) format('woff2'); 175 | unicode-range: U+1F00-1FFF; 176 | } 177 | /* greek */ 178 | @font-face { 179 | font-family: 'Roboto'; 180 | font-style: normal; 181 | font-weight: 400; 182 | src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4WxKKTU1Kvnz.woff2) format('woff2'); 183 | unicode-range: U+0370-03FF; 184 | } 185 | /* vietnamese */ 186 | @font-face { 187 | font-family: 'Roboto'; 188 | font-style: normal; 189 | font-weight: 400; 190 | src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu7WxKKTU1Kvnz.woff2) format('woff2'); 191 | unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB; 192 | } 193 | /* latin-ext */ 194 | @font-face { 195 | font-family: 'Roboto'; 196 | font-style: normal; 197 | font-weight: 400; 198 | src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu7GxKKTU1Kvnz.woff2) format('woff2'); 199 | unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; 200 | } 201 | /* latin */ 202 | @font-face { 203 | font-family: 'Roboto'; 204 | font-style: normal; 205 | font-weight: 400; 206 | src: url(https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2) format('woff2'); 207 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; 208 | } 209 | -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf 9 | 10 | -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/app/bin/main/dangling/pointer/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-dangling-pointer-attempt/app/bin/main/dangling/pointer/App.class -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/app/bin/test/dangling/pointer/AppTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-dangling-pointer-attempt/app/bin/test/dangling/pointer/AppTest.class -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This generated file contains a sample Java application project to get you started. 5 | * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle 6 | * User Manual available at https://docs.gradle.org/7.6/userguide/building_java_projects.html 7 | */ 8 | 9 | plugins { 10 | // Apply the application plugin to add support for building a CLI application in Java. 11 | application 12 | } 13 | 14 | repositories { 15 | // Use Maven Central for resolving dependencies. 16 | mavenCentral() 17 | } 18 | 19 | dependencies { 20 | // Use JUnit test framework. 21 | testImplementation("junit:junit:4.13.2") 22 | 23 | // This dependency is used by the application. 24 | implementation("com.google.guava:guava:31.1-jre") 25 | } 26 | 27 | application { 28 | // Define the main class for the application. 29 | mainClass.set("dangling.pointer.App") 30 | } 31 | -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/app/src/main/java/dangling/pointer/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package dangling.pointer; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class App { 9 | public static void main(String[] args) throws Exception { 10 | // Create an ArrayList and store numbers 1,2,3 in it 11 | var danglingPointer = new ArrayList(5); 12 | danglingPointer.add(1); 13 | danglingPointer.add(2); 14 | danglingPointer.add(3); 15 | 16 | var danglingPointerCopy = danglingPointer; 17 | danglingPointer = null; 18 | System.out.println(danglingPointerCopy); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/app/src/test/java/dangling/pointer/AppTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package dangling.pointer; 5 | 6 | import org.junit.Test; 7 | import static org.junit.Assert.*; 8 | 9 | public class AppTest { 10 | @Test public void appHasAGreeting() { 11 | App classUnderTest = new App(); 12 | // assertNotNull("app should have a greeting", classUnderTest.getGreeting()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-dangling-pointer-attempt/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 147 | # shellcheck disable=SC3045 148 | MAX_FD=$( ulimit -H -n ) || 149 | warn "Could not query maximum file descriptor limit" 150 | esac 151 | case $MAX_FD in #( 152 | '' | soft) :;; #( 153 | *) 154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 155 | # shellcheck disable=SC3045 156 | ulimit -n "$MAX_FD" || 157 | warn "Could not set maximum file descriptor limit to $MAX_FD" 158 | esac 159 | fi 160 | 161 | # Collect all arguments for the java command, stacking in reverse order: 162 | # * args from the command line 163 | # * the main class name 164 | # * -classpath 165 | # * -D...appname settings 166 | # * --module-path (only if needed) 167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 168 | 169 | # For Cygwin or MSYS, switch paths to Windows format before running java 170 | if "$cygwin" || "$msys" ; then 171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 173 | 174 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 175 | 176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 177 | for arg do 178 | if 179 | case $arg in #( 180 | -*) false ;; # don't mess with options #( 181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 182 | [ -e "$t" ] ;; #( 183 | *) false ;; 184 | esac 185 | then 186 | arg=$( cygpath --path --ignore --mixed "$arg" ) 187 | fi 188 | # Roll the args list around exactly as many times as the number of 189 | # args, so each arg winds up back in the position where it started, but 190 | # possibly modified. 191 | # 192 | # NB: a `for` loop captures its iteration list before it begins, so 193 | # changing the positional parameters here affects neither the number of 194 | # iterations, nor the values presented in `arg`. 195 | shift # remove old arg 196 | set -- "$@" "$arg" # push replacement arg 197 | done 198 | fi 199 | 200 | # Collect all arguments for the java command; 201 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 202 | # shell script including quotes and variable substitutions, so put them in 203 | # double quotes to make sure that they get re-expanded; and 204 | # * put everything else in single quotes, so that it's not re-expanded. 205 | 206 | set -- \ 207 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 208 | -classpath "$CLASSPATH" \ 209 | org.gradle.wrapper.GradleWrapperMain \ 210 | "$@" 211 | 212 | # Stop when "xargs" is not available. 213 | if ! command -v xargs >/dev/null 2>&1 214 | then 215 | die "xargs is not available" 216 | fi 217 | 218 | # Use "xargs" to parse quoted args. 219 | # 220 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 221 | # 222 | # In Bash we could simply go: 223 | # 224 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 225 | # set -- "${ARGS[@]}" "$@" 226 | # 227 | # but POSIX shell has neither arrays nor command substitution, so instead we 228 | # post-process each arg (as a line of input to sed) to backslash-escape any 229 | # character that might be a shell metacharacter, then use eval to reverse 230 | # that process (while maintaining the separation between arguments), and wrap 231 | # the whole thing up as a single "set" statement. 232 | # 233 | # This will of course break if any of these variables contains a newline or 234 | # an unmatched quote. 235 | # 236 | 237 | eval "set -- $( 238 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 239 | xargs -n1 | 240 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 241 | tr '\n' ' ' 242 | )" '"$@"' 243 | 244 | exec "$JAVACMD" "$@" 245 | -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /java-dangling-pointer-attempt/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.6/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = "dangling-pointer" 11 | include("app") 12 | -------------------------------------------------------------------------------- /java-deadlock/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf 9 | 10 | -------------------------------------------------------------------------------- /java-deadlock/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /java-deadlock/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "automatic" 3 | } -------------------------------------------------------------------------------- /java-deadlock/app/bin/main/jav/deadlock/App$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-deadlock/app/bin/main/jav/deadlock/App$1.class -------------------------------------------------------------------------------- /java-deadlock/app/bin/main/jav/deadlock/App$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-deadlock/app/bin/main/jav/deadlock/App$2.class -------------------------------------------------------------------------------- /java-deadlock/app/bin/main/jav/deadlock/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-deadlock/app/bin/main/jav/deadlock/App.class -------------------------------------------------------------------------------- /java-deadlock/app/bin/test/jav/deadlock/AppTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-deadlock/app/bin/test/jav/deadlock/AppTest.class -------------------------------------------------------------------------------- /java-deadlock/app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This generated file contains a sample Java application project to get you started. 5 | * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle 6 | * User Manual available at https://docs.gradle.org/7.6/userguide/building_java_projects.html 7 | */ 8 | 9 | plugins { 10 | // Apply the application plugin to add support for building a CLI application in Java. 11 | id 'application' 12 | } 13 | 14 | repositories { 15 | // Use Maven Central for resolving dependencies. 16 | mavenCentral() 17 | } 18 | 19 | dependencies { 20 | // Use JUnit test framework. 21 | testImplementation 'junit:junit:4.13.2' 22 | 23 | // This dependency is used by the application. 24 | implementation 'com.google.guava:guava:31.1-jre' 25 | } 26 | 27 | application { 28 | // Define the main class for the application. 29 | mainClass = 'jav.deadlock.App' 30 | } 31 | -------------------------------------------------------------------------------- /java-deadlock/app/src/main/java/jav/deadlock/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package jav.deadlock; 5 | 6 | public class App { 7 | 8 | public static void main(String[] args) { 9 | Object lock1 = new Object(); 10 | Object lock2 = new Object(); 11 | var t1 = new Thread(new Runnable() { 12 | public void run() { 13 | synchronized(lock1) { 14 | System.out.println("Thread 1 lock1"); 15 | try { 16 | Thread.sleep(100); 17 | } catch (InterruptedException e) { 18 | e.printStackTrace(); 19 | } 20 | synchronized(lock2) { 21 | System.out.println("Thread 1 lock2"); 22 | } 23 | } 24 | } 25 | }); 26 | 27 | var t2 = new Thread(new Runnable() { 28 | public void run() { 29 | synchronized(lock2) { 30 | System.out.println("Thread 2 lock2"); 31 | try { 32 | Thread.sleep(100); 33 | } catch (InterruptedException e) { 34 | e.printStackTrace(); 35 | } 36 | synchronized(lock1) { 37 | System.out.println("Thread 2 lock2"); 38 | } 39 | } 40 | } 41 | }); 42 | 43 | t1.start(); 44 | t2.start(); 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /java-deadlock/app/src/test/java/jav/deadlock/AppTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package jav.deadlock; 5 | 6 | import org.junit.Test; 7 | 8 | import jav.deadlock.App; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | public class AppTest { 13 | @Test public void appHasAGreeting() { 14 | App classUnderTest = new App(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-deadlock/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-deadlock/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /java-deadlock/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /java-deadlock/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 147 | # shellcheck disable=SC3045 148 | MAX_FD=$( ulimit -H -n ) || 149 | warn "Could not query maximum file descriptor limit" 150 | esac 151 | case $MAX_FD in #( 152 | '' | soft) :;; #( 153 | *) 154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 155 | # shellcheck disable=SC3045 156 | ulimit -n "$MAX_FD" || 157 | warn "Could not set maximum file descriptor limit to $MAX_FD" 158 | esac 159 | fi 160 | 161 | # Collect all arguments for the java command, stacking in reverse order: 162 | # * args from the command line 163 | # * the main class name 164 | # * -classpath 165 | # * -D...appname settings 166 | # * --module-path (only if needed) 167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 168 | 169 | # For Cygwin or MSYS, switch paths to Windows format before running java 170 | if "$cygwin" || "$msys" ; then 171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 173 | 174 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 175 | 176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 177 | for arg do 178 | if 179 | case $arg in #( 180 | -*) false ;; # don't mess with options #( 181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 182 | [ -e "$t" ] ;; #( 183 | *) false ;; 184 | esac 185 | then 186 | arg=$( cygpath --path --ignore --mixed "$arg" ) 187 | fi 188 | # Roll the args list around exactly as many times as the number of 189 | # args, so each arg winds up back in the position where it started, but 190 | # possibly modified. 191 | # 192 | # NB: a `for` loop captures its iteration list before it begins, so 193 | # changing the positional parameters here affects neither the number of 194 | # iterations, nor the values presented in `arg`. 195 | shift # remove old arg 196 | set -- "$@" "$arg" # push replacement arg 197 | done 198 | fi 199 | 200 | # Collect all arguments for the java command; 201 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 202 | # shell script including quotes and variable substitutions, so put them in 203 | # double quotes to make sure that they get re-expanded; and 204 | # * put everything else in single quotes, so that it's not re-expanded. 205 | 206 | set -- \ 207 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 208 | -classpath "$CLASSPATH" \ 209 | org.gradle.wrapper.GradleWrapperMain \ 210 | "$@" 211 | 212 | # Stop when "xargs" is not available. 213 | if ! command -v xargs >/dev/null 2>&1 214 | then 215 | die "xargs is not available" 216 | fi 217 | 218 | # Use "xargs" to parse quoted args. 219 | # 220 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 221 | # 222 | # In Bash we could simply go: 223 | # 224 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 225 | # set -- "${ARGS[@]}" "$@" 226 | # 227 | # but POSIX shell has neither arrays nor command substitution, so instead we 228 | # post-process each arg (as a line of input to sed) to backslash-escape any 229 | # character that might be a shell metacharacter, then use eval to reverse 230 | # that process (while maintaining the separation between arguments), and wrap 231 | # the whole thing up as a single "set" statement. 232 | # 233 | # This will of course break if any of these variables contains a newline or 234 | # an unmatched quote. 235 | # 236 | 237 | eval "set -- $( 238 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 239 | xargs -n1 | 240 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 241 | tr '\n' ' ' 242 | )" '"$@"' 243 | 244 | exec "$JAVACMD" "$@" 245 | -------------------------------------------------------------------------------- /java-deadlock/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /java-deadlock/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.6/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'java-deadlock' 11 | include('app') 12 | -------------------------------------------------------------------------------- /java-mpmc-sample/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf 9 | 10 | -------------------------------------------------------------------------------- /java-mpmc-sample/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /java-mpmc-sample/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.configuration.updateBuildConfiguration": "interactive" 3 | } -------------------------------------------------------------------------------- /java-mpmc-sample/app/bin/main/jav/mpmc/sample/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-mpmc-sample/app/bin/main/jav/mpmc/sample/App.class -------------------------------------------------------------------------------- /java-mpmc-sample/app/bin/test/jav/mpmc/sample/AppTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-mpmc-sample/app/bin/test/jav/mpmc/sample/AppTest.class -------------------------------------------------------------------------------- /java-mpmc-sample/app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This generated file contains a sample Java application project to get you started. 5 | * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle 6 | * User Manual available at https://docs.gradle.org/7.6/userguide/building_java_projects.html 7 | */ 8 | 9 | plugins { 10 | // Apply the application plugin to add support for building a CLI application in Java. 11 | id 'application' 12 | } 13 | 14 | repositories { 15 | // Use Maven Central for resolving dependencies. 16 | mavenCentral() 17 | } 18 | 19 | dependencies { 20 | // Use JUnit test framework. 21 | testImplementation 'junit:junit:4.13.2' 22 | 23 | // This dependency is used by the application. 24 | implementation 'com.google.guava:guava:31.1-jre' 25 | } 26 | 27 | application { 28 | // Define the main class for the application. 29 | mainClass = 'jav.mpmc.sample.App' 30 | } 31 | -------------------------------------------------------------------------------- /java-mpmc-sample/app/src/main/java/jav/mpmc/sample/App.java: -------------------------------------------------------------------------------- 1 | package jav.mpmc.sample; 2 | 3 | import java.util.ArrayList; 4 | import java.util.concurrent.ConcurrentLinkedQueue; 5 | 6 | public class App { 7 | public static void main(String[] args) throws InterruptedException { 8 | // Create a concurrent linked queue to hold the messages 9 | final var queue = new ConcurrentLinkedQueue(); 10 | 11 | // Spawn producer threads 12 | for (int i = 0; i < 5; i++) { 13 | final var acc = i; 14 | new Thread(() -> { 15 | queue.add(acc *2); 16 | }).start(); 17 | } 18 | // Spawn consumer threads 19 | var handles = new ArrayList(); 20 | for (int i = 0; i < 5; i++) { 21 | var thread = new Thread(() -> { 22 | while (true) { 23 | var message = queue.poll(); 24 | if (message != null) { 25 | System.out.println("received value " + message); 26 | return; 27 | } 28 | } 29 | }); 30 | thread.start(); 31 | handles.add(thread); 32 | } 33 | // iterate over all threads and wait for them to finish 34 | for (var handle : handles) { 35 | handle.join(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /java-mpmc-sample/app/src/test/java/jav/mpmc/sample/AppTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package jav.mpmc.sample; 5 | 6 | import org.junit.Test; 7 | 8 | import jav.mpmc.sample.App; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | public class AppTest { 13 | @Test public void appHasAGreeting() { 14 | App classUnderTest = new App(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /java-mpmc-sample/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-mpmc-sample/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /java-mpmc-sample/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /java-mpmc-sample/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 147 | # shellcheck disable=SC3045 148 | MAX_FD=$( ulimit -H -n ) || 149 | warn "Could not query maximum file descriptor limit" 150 | esac 151 | case $MAX_FD in #( 152 | '' | soft) :;; #( 153 | *) 154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 155 | # shellcheck disable=SC3045 156 | ulimit -n "$MAX_FD" || 157 | warn "Could not set maximum file descriptor limit to $MAX_FD" 158 | esac 159 | fi 160 | 161 | # Collect all arguments for the java command, stacking in reverse order: 162 | # * args from the command line 163 | # * the main class name 164 | # * -classpath 165 | # * -D...appname settings 166 | # * --module-path (only if needed) 167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 168 | 169 | # For Cygwin or MSYS, switch paths to Windows format before running java 170 | if "$cygwin" || "$msys" ; then 171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 173 | 174 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 175 | 176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 177 | for arg do 178 | if 179 | case $arg in #( 180 | -*) false ;; # don't mess with options #( 181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 182 | [ -e "$t" ] ;; #( 183 | *) false ;; 184 | esac 185 | then 186 | arg=$( cygpath --path --ignore --mixed "$arg" ) 187 | fi 188 | # Roll the args list around exactly as many times as the number of 189 | # args, so each arg winds up back in the position where it started, but 190 | # possibly modified. 191 | # 192 | # NB: a `for` loop captures its iteration list before it begins, so 193 | # changing the positional parameters here affects neither the number of 194 | # iterations, nor the values presented in `arg`. 195 | shift # remove old arg 196 | set -- "$@" "$arg" # push replacement arg 197 | done 198 | fi 199 | 200 | # Collect all arguments for the java command; 201 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 202 | # shell script including quotes and variable substitutions, so put them in 203 | # double quotes to make sure that they get re-expanded; and 204 | # * put everything else in single quotes, so that it's not re-expanded. 205 | 206 | set -- \ 207 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 208 | -classpath "$CLASSPATH" \ 209 | org.gradle.wrapper.GradleWrapperMain \ 210 | "$@" 211 | 212 | # Stop when "xargs" is not available. 213 | if ! command -v xargs >/dev/null 2>&1 214 | then 215 | die "xargs is not available" 216 | fi 217 | 218 | # Use "xargs" to parse quoted args. 219 | # 220 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 221 | # 222 | # In Bash we could simply go: 223 | # 224 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 225 | # set -- "${ARGS[@]}" "$@" 226 | # 227 | # but POSIX shell has neither arrays nor command substitution, so instead we 228 | # post-process each arg (as a line of input to sed) to backslash-escape any 229 | # character that might be a shell metacharacter, then use eval to reverse 230 | # that process (while maintaining the separation between arguments), and wrap 231 | # the whole thing up as a single "set" statement. 232 | # 233 | # This will of course break if any of these variables contains a newline or 234 | # an unmatched quote. 235 | # 236 | 237 | eval "set -- $( 238 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 239 | xargs -n1 | 240 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 241 | tr '\n' ' ' 242 | )" '"$@"' 243 | 244 | exec "$JAVACMD" "$@" 245 | -------------------------------------------------------------------------------- /java-mpmc-sample/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /java-mpmc-sample/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.6/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'java-mpmc-sample' 11 | include('app') 12 | -------------------------------------------------------------------------------- /java-null-pointer/.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf 9 | 10 | -------------------------------------------------------------------------------- /java-null-pointer/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Gradle project-specific cache directory 2 | .gradle 3 | 4 | # Ignore Gradle build output directory 5 | build 6 | -------------------------------------------------------------------------------- /java-null-pointer/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "java.compile.nullAnalysis.mode": "disabled", 3 | "java.configuration.updateBuildConfiguration": "automatic" 4 | } -------------------------------------------------------------------------------- /java-null-pointer/app/bin/main/javanullpointer/App.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-null-pointer/app/bin/main/javanullpointer/App.class -------------------------------------------------------------------------------- /java-null-pointer/app/bin/test/javanullpointer/AppTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-null-pointer/app/bin/test/javanullpointer/AppTest.class -------------------------------------------------------------------------------- /java-null-pointer/app/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * This generated file contains a sample Java application project to get you started. 5 | * For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle 6 | * User Manual available at https://docs.gradle.org/7.6/userguide/building_java_projects.html 7 | */ 8 | 9 | plugins { 10 | // Apply the application plugin to add support for building a CLI application in Java. 11 | id 'application' 12 | id 'org.checkerframework' version '0.6.20' 13 | 14 | } 15 | 16 | repositories { 17 | // Use Maven Central for resolving dependencies. 18 | mavenCentral() 19 | } 20 | 21 | dependencies { 22 | // Use JUnit test framework. 23 | testImplementation 'junit:junit:4.13.2' 24 | 25 | // This dependency is used by the application. 26 | implementation 'com.google.guava:guava:31.1-jre' 27 | } 28 | 29 | application { 30 | // Define the main class for the application. 31 | mainClass = 'javanullpointer.App' 32 | } 33 | 34 | checkerFramework { 35 | checkers = [ 36 | 'org.checkerframework.checker.nullness.NullnessChecker', 37 | 'org.checkerframework.checker.units.UnitsChecker' 38 | ] 39 | } 40 | 41 | apply plugin: 'org.checkerframework' 42 | -------------------------------------------------------------------------------- /java-null-pointer/app/src/main/java/javanullpointer/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package javanullpointer; 5 | import java.util.*; 6 | 7 | public class App { 8 | public static void main(String[] args) { 9 | Scanner sc = new Scanner(System.in); 10 | String a = (sc.nextLine() == "crash") ? null : "no crash"; 11 | sc.close(); 12 | System.out.println(a.length()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /java-null-pointer/app/src/test/java/javanullpointer/AppTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This Java source file was generated by the Gradle 'init' task. 3 | */ 4 | package javanullpointer; 5 | 6 | import org.junit.Test; 7 | import static org.junit.Assert.*; 8 | 9 | public class AppTest { 10 | @Test public void appHasAGreeting() { 11 | App classUnderTest = new App(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /java-null-pointer/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/security-union/rust-vs-java/ded151ec92ef9c4e95bc6a7120eb8ebf0ede3b98/java-null-pointer/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /java-null-pointer/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /java-null-pointer/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 147 | # shellcheck disable=SC3045 148 | MAX_FD=$( ulimit -H -n ) || 149 | warn "Could not query maximum file descriptor limit" 150 | esac 151 | case $MAX_FD in #( 152 | '' | soft) :;; #( 153 | *) 154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 155 | # shellcheck disable=SC3045 156 | ulimit -n "$MAX_FD" || 157 | warn "Could not set maximum file descriptor limit to $MAX_FD" 158 | esac 159 | fi 160 | 161 | # Collect all arguments for the java command, stacking in reverse order: 162 | # * args from the command line 163 | # * the main class name 164 | # * -classpath 165 | # * -D...appname settings 166 | # * --module-path (only if needed) 167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 168 | 169 | # For Cygwin or MSYS, switch paths to Windows format before running java 170 | if "$cygwin" || "$msys" ; then 171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 173 | 174 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 175 | 176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 177 | for arg do 178 | if 179 | case $arg in #( 180 | -*) false ;; # don't mess with options #( 181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 182 | [ -e "$t" ] ;; #( 183 | *) false ;; 184 | esac 185 | then 186 | arg=$( cygpath --path --ignore --mixed "$arg" ) 187 | fi 188 | # Roll the args list around exactly as many times as the number of 189 | # args, so each arg winds up back in the position where it started, but 190 | # possibly modified. 191 | # 192 | # NB: a `for` loop captures its iteration list before it begins, so 193 | # changing the positional parameters here affects neither the number of 194 | # iterations, nor the values presented in `arg`. 195 | shift # remove old arg 196 | set -- "$@" "$arg" # push replacement arg 197 | done 198 | fi 199 | 200 | # Collect all arguments for the java command; 201 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 202 | # shell script including quotes and variable substitutions, so put them in 203 | # double quotes to make sure that they get re-expanded; and 204 | # * put everything else in single quotes, so that it's not re-expanded. 205 | 206 | set -- \ 207 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 208 | -classpath "$CLASSPATH" \ 209 | org.gradle.wrapper.GradleWrapperMain \ 210 | "$@" 211 | 212 | # Stop when "xargs" is not available. 213 | if ! command -v xargs >/dev/null 2>&1 214 | then 215 | die "xargs is not available" 216 | fi 217 | 218 | # Use "xargs" to parse quoted args. 219 | # 220 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 221 | # 222 | # In Bash we could simply go: 223 | # 224 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 225 | # set -- "${ARGS[@]}" "$@" 226 | # 227 | # but POSIX shell has neither arrays nor command substitution, so instead we 228 | # post-process each arg (as a line of input to sed) to backslash-escape any 229 | # character that might be a shell metacharacter, then use eval to reverse 230 | # that process (while maintaining the separation between arguments), and wrap 231 | # the whole thing up as a single "set" statement. 232 | # 233 | # This will of course break if any of these variables contains a newline or 234 | # an unmatched quote. 235 | # 236 | 237 | eval "set -- $( 238 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 239 | xargs -n1 | 240 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 241 | tr '\n' ' ' 242 | )" '"$@"' 243 | 244 | exec "$JAVACMD" "$@" 245 | -------------------------------------------------------------------------------- /java-null-pointer/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /java-null-pointer/settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/7.6/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'JavaNullPointer' 11 | include('app') 12 | -------------------------------------------------------------------------------- /rust-actix-hello-world/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /rust-actix-hello-world/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "actix-codec" 7 | version = "0.5.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "57a7559404a7f3573127aab53c08ce37a6c6a315c374a31070f3c91cd1b4a7fe" 10 | dependencies = [ 11 | "bitflags", 12 | "bytes", 13 | "futures-core", 14 | "futures-sink", 15 | "log", 16 | "memchr", 17 | "pin-project-lite", 18 | "tokio", 19 | "tokio-util", 20 | ] 21 | 22 | [[package]] 23 | name = "actix-hello-world" 24 | version = "0.1.0" 25 | dependencies = [ 26 | "actix-web", 27 | ] 28 | 29 | [[package]] 30 | name = "actix-http" 31 | version = "3.2.2" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "0c83abf9903e1f0ad9973cc4f7b9767fd5a03a583f51a5b7a339e07987cd2724" 34 | dependencies = [ 35 | "actix-codec", 36 | "actix-rt", 37 | "actix-service", 38 | "actix-utils", 39 | "ahash", 40 | "base64", 41 | "bitflags", 42 | "brotli", 43 | "bytes", 44 | "bytestring", 45 | "derive_more", 46 | "encoding_rs", 47 | "flate2", 48 | "futures-core", 49 | "h2", 50 | "http", 51 | "httparse", 52 | "httpdate", 53 | "itoa", 54 | "language-tags", 55 | "local-channel", 56 | "mime", 57 | "percent-encoding", 58 | "pin-project-lite", 59 | "rand", 60 | "sha1", 61 | "smallvec", 62 | "tracing", 63 | "zstd", 64 | ] 65 | 66 | [[package]] 67 | name = "actix-macros" 68 | version = "0.2.3" 69 | source = "registry+https://github.com/rust-lang/crates.io-index" 70 | checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" 71 | dependencies = [ 72 | "quote", 73 | "syn", 74 | ] 75 | 76 | [[package]] 77 | name = "actix-router" 78 | version = "0.5.1" 79 | source = "registry+https://github.com/rust-lang/crates.io-index" 80 | checksum = "d66ff4d247d2b160861fa2866457e85706833527840e4133f8f49aa423a38799" 81 | dependencies = [ 82 | "bytestring", 83 | "http", 84 | "regex", 85 | "serde", 86 | "tracing", 87 | ] 88 | 89 | [[package]] 90 | name = "actix-rt" 91 | version = "2.7.0" 92 | source = "registry+https://github.com/rust-lang/crates.io-index" 93 | checksum = "7ea16c295198e958ef31930a6ef37d0fb64e9ca3b6116e6b93a8bdae96ee1000" 94 | dependencies = [ 95 | "futures-core", 96 | "tokio", 97 | ] 98 | 99 | [[package]] 100 | name = "actix-server" 101 | version = "2.1.1" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "0da34f8e659ea1b077bb4637948b815cd3768ad5a188fdcd74ff4d84240cd824" 104 | dependencies = [ 105 | "actix-rt", 106 | "actix-service", 107 | "actix-utils", 108 | "futures-core", 109 | "futures-util", 110 | "mio", 111 | "num_cpus", 112 | "socket2", 113 | "tokio", 114 | "tracing", 115 | ] 116 | 117 | [[package]] 118 | name = "actix-service" 119 | version = "2.0.2" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" 122 | dependencies = [ 123 | "futures-core", 124 | "paste", 125 | "pin-project-lite", 126 | ] 127 | 128 | [[package]] 129 | name = "actix-utils" 130 | version = "3.0.1" 131 | source = "registry+https://github.com/rust-lang/crates.io-index" 132 | checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" 133 | dependencies = [ 134 | "local-waker", 135 | "pin-project-lite", 136 | ] 137 | 138 | [[package]] 139 | name = "actix-web" 140 | version = "4.2.1" 141 | source = "registry+https://github.com/rust-lang/crates.io-index" 142 | checksum = "d48f7b6534e06c7bfc72ee91db7917d4af6afe23e7d223b51e68fffbb21e96b9" 143 | dependencies = [ 144 | "actix-codec", 145 | "actix-http", 146 | "actix-macros", 147 | "actix-router", 148 | "actix-rt", 149 | "actix-server", 150 | "actix-service", 151 | "actix-utils", 152 | "actix-web-codegen", 153 | "ahash", 154 | "bytes", 155 | "bytestring", 156 | "cfg-if", 157 | "cookie", 158 | "derive_more", 159 | "encoding_rs", 160 | "futures-core", 161 | "futures-util", 162 | "http", 163 | "itoa", 164 | "language-tags", 165 | "log", 166 | "mime", 167 | "once_cell", 168 | "pin-project-lite", 169 | "regex", 170 | "serde", 171 | "serde_json", 172 | "serde_urlencoded", 173 | "smallvec", 174 | "socket2", 175 | "time", 176 | "url", 177 | ] 178 | 179 | [[package]] 180 | name = "actix-web-codegen" 181 | version = "4.1.0" 182 | source = "registry+https://github.com/rust-lang/crates.io-index" 183 | checksum = "1fa9362663c8643d67b2d5eafba49e4cb2c8a053a29ed00a0bea121f17c76b13" 184 | dependencies = [ 185 | "actix-router", 186 | "proc-macro2", 187 | "quote", 188 | "syn", 189 | ] 190 | 191 | [[package]] 192 | name = "adler" 193 | version = "1.0.2" 194 | source = "registry+https://github.com/rust-lang/crates.io-index" 195 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 196 | 197 | [[package]] 198 | name = "ahash" 199 | version = "0.7.6" 200 | source = "registry+https://github.com/rust-lang/crates.io-index" 201 | checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" 202 | dependencies = [ 203 | "getrandom", 204 | "once_cell", 205 | "version_check", 206 | ] 207 | 208 | [[package]] 209 | name = "aho-corasick" 210 | version = "0.7.20" 211 | source = "registry+https://github.com/rust-lang/crates.io-index" 212 | checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" 213 | dependencies = [ 214 | "memchr", 215 | ] 216 | 217 | [[package]] 218 | name = "alloc-no-stdlib" 219 | version = "2.0.4" 220 | source = "registry+https://github.com/rust-lang/crates.io-index" 221 | checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" 222 | 223 | [[package]] 224 | name = "alloc-stdlib" 225 | version = "0.2.2" 226 | source = "registry+https://github.com/rust-lang/crates.io-index" 227 | checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" 228 | dependencies = [ 229 | "alloc-no-stdlib", 230 | ] 231 | 232 | [[package]] 233 | name = "autocfg" 234 | version = "1.1.0" 235 | source = "registry+https://github.com/rust-lang/crates.io-index" 236 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 237 | 238 | [[package]] 239 | name = "base64" 240 | version = "0.13.1" 241 | source = "registry+https://github.com/rust-lang/crates.io-index" 242 | checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" 243 | 244 | [[package]] 245 | name = "bitflags" 246 | version = "1.3.2" 247 | source = "registry+https://github.com/rust-lang/crates.io-index" 248 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 249 | 250 | [[package]] 251 | name = "block-buffer" 252 | version = "0.10.3" 253 | source = "registry+https://github.com/rust-lang/crates.io-index" 254 | checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" 255 | dependencies = [ 256 | "generic-array", 257 | ] 258 | 259 | [[package]] 260 | name = "brotli" 261 | version = "3.3.4" 262 | source = "registry+https://github.com/rust-lang/crates.io-index" 263 | checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" 264 | dependencies = [ 265 | "alloc-no-stdlib", 266 | "alloc-stdlib", 267 | "brotli-decompressor", 268 | ] 269 | 270 | [[package]] 271 | name = "brotli-decompressor" 272 | version = "2.3.2" 273 | source = "registry+https://github.com/rust-lang/crates.io-index" 274 | checksum = "59ad2d4653bf5ca36ae797b1f4bb4dbddb60ce49ca4aed8a2ce4829f60425b80" 275 | dependencies = [ 276 | "alloc-no-stdlib", 277 | "alloc-stdlib", 278 | ] 279 | 280 | [[package]] 281 | name = "bytes" 282 | version = "1.3.0" 283 | source = "registry+https://github.com/rust-lang/crates.io-index" 284 | checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" 285 | 286 | [[package]] 287 | name = "bytestring" 288 | version = "1.2.0" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | checksum = "f7f83e57d9154148e355404702e2694463241880b939570d7c97c014da7a69a1" 291 | dependencies = [ 292 | "bytes", 293 | ] 294 | 295 | [[package]] 296 | name = "cc" 297 | version = "1.0.78" 298 | source = "registry+https://github.com/rust-lang/crates.io-index" 299 | checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" 300 | dependencies = [ 301 | "jobserver", 302 | ] 303 | 304 | [[package]] 305 | name = "cfg-if" 306 | version = "1.0.0" 307 | source = "registry+https://github.com/rust-lang/crates.io-index" 308 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 309 | 310 | [[package]] 311 | name = "convert_case" 312 | version = "0.4.0" 313 | source = "registry+https://github.com/rust-lang/crates.io-index" 314 | checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" 315 | 316 | [[package]] 317 | name = "cookie" 318 | version = "0.16.2" 319 | source = "registry+https://github.com/rust-lang/crates.io-index" 320 | checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" 321 | dependencies = [ 322 | "percent-encoding", 323 | "time", 324 | "version_check", 325 | ] 326 | 327 | [[package]] 328 | name = "cpufeatures" 329 | version = "0.2.5" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" 332 | dependencies = [ 333 | "libc", 334 | ] 335 | 336 | [[package]] 337 | name = "crc32fast" 338 | version = "1.3.2" 339 | source = "registry+https://github.com/rust-lang/crates.io-index" 340 | checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" 341 | dependencies = [ 342 | "cfg-if", 343 | ] 344 | 345 | [[package]] 346 | name = "crypto-common" 347 | version = "0.1.6" 348 | source = "registry+https://github.com/rust-lang/crates.io-index" 349 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 350 | dependencies = [ 351 | "generic-array", 352 | "typenum", 353 | ] 354 | 355 | [[package]] 356 | name = "derive_more" 357 | version = "0.99.17" 358 | source = "registry+https://github.com/rust-lang/crates.io-index" 359 | checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" 360 | dependencies = [ 361 | "convert_case", 362 | "proc-macro2", 363 | "quote", 364 | "rustc_version", 365 | "syn", 366 | ] 367 | 368 | [[package]] 369 | name = "digest" 370 | version = "0.10.6" 371 | source = "registry+https://github.com/rust-lang/crates.io-index" 372 | checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" 373 | dependencies = [ 374 | "block-buffer", 375 | "crypto-common", 376 | ] 377 | 378 | [[package]] 379 | name = "encoding_rs" 380 | version = "0.8.31" 381 | source = "registry+https://github.com/rust-lang/crates.io-index" 382 | checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" 383 | dependencies = [ 384 | "cfg-if", 385 | ] 386 | 387 | [[package]] 388 | name = "flate2" 389 | version = "1.0.25" 390 | source = "registry+https://github.com/rust-lang/crates.io-index" 391 | checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" 392 | dependencies = [ 393 | "crc32fast", 394 | "miniz_oxide", 395 | ] 396 | 397 | [[package]] 398 | name = "fnv" 399 | version = "1.0.7" 400 | source = "registry+https://github.com/rust-lang/crates.io-index" 401 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 402 | 403 | [[package]] 404 | name = "form_urlencoded" 405 | version = "1.1.0" 406 | source = "registry+https://github.com/rust-lang/crates.io-index" 407 | checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" 408 | dependencies = [ 409 | "percent-encoding", 410 | ] 411 | 412 | [[package]] 413 | name = "futures-core" 414 | version = "0.3.25" 415 | source = "registry+https://github.com/rust-lang/crates.io-index" 416 | checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" 417 | 418 | [[package]] 419 | name = "futures-sink" 420 | version = "0.3.25" 421 | source = "registry+https://github.com/rust-lang/crates.io-index" 422 | checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" 423 | 424 | [[package]] 425 | name = "futures-task" 426 | version = "0.3.25" 427 | source = "registry+https://github.com/rust-lang/crates.io-index" 428 | checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" 429 | 430 | [[package]] 431 | name = "futures-util" 432 | version = "0.3.25" 433 | source = "registry+https://github.com/rust-lang/crates.io-index" 434 | checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" 435 | dependencies = [ 436 | "futures-core", 437 | "futures-task", 438 | "pin-project-lite", 439 | "pin-utils", 440 | ] 441 | 442 | [[package]] 443 | name = "generic-array" 444 | version = "0.14.6" 445 | source = "registry+https://github.com/rust-lang/crates.io-index" 446 | checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" 447 | dependencies = [ 448 | "typenum", 449 | "version_check", 450 | ] 451 | 452 | [[package]] 453 | name = "getrandom" 454 | version = "0.2.8" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" 457 | dependencies = [ 458 | "cfg-if", 459 | "libc", 460 | "wasi", 461 | ] 462 | 463 | [[package]] 464 | name = "h2" 465 | version = "0.3.15" 466 | source = "registry+https://github.com/rust-lang/crates.io-index" 467 | checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" 468 | dependencies = [ 469 | "bytes", 470 | "fnv", 471 | "futures-core", 472 | "futures-sink", 473 | "futures-util", 474 | "http", 475 | "indexmap", 476 | "slab", 477 | "tokio", 478 | "tokio-util", 479 | "tracing", 480 | ] 481 | 482 | [[package]] 483 | name = "hashbrown" 484 | version = "0.12.3" 485 | source = "registry+https://github.com/rust-lang/crates.io-index" 486 | checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" 487 | 488 | [[package]] 489 | name = "hermit-abi" 490 | version = "0.2.6" 491 | source = "registry+https://github.com/rust-lang/crates.io-index" 492 | checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" 493 | dependencies = [ 494 | "libc", 495 | ] 496 | 497 | [[package]] 498 | name = "http" 499 | version = "0.2.8" 500 | source = "registry+https://github.com/rust-lang/crates.io-index" 501 | checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" 502 | dependencies = [ 503 | "bytes", 504 | "fnv", 505 | "itoa", 506 | ] 507 | 508 | [[package]] 509 | name = "httparse" 510 | version = "1.8.0" 511 | source = "registry+https://github.com/rust-lang/crates.io-index" 512 | checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" 513 | 514 | [[package]] 515 | name = "httpdate" 516 | version = "1.0.2" 517 | source = "registry+https://github.com/rust-lang/crates.io-index" 518 | checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" 519 | 520 | [[package]] 521 | name = "idna" 522 | version = "0.3.0" 523 | source = "registry+https://github.com/rust-lang/crates.io-index" 524 | checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" 525 | dependencies = [ 526 | "unicode-bidi", 527 | "unicode-normalization", 528 | ] 529 | 530 | [[package]] 531 | name = "indexmap" 532 | version = "1.9.2" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" 535 | dependencies = [ 536 | "autocfg", 537 | "hashbrown", 538 | ] 539 | 540 | [[package]] 541 | name = "itoa" 542 | version = "1.0.5" 543 | source = "registry+https://github.com/rust-lang/crates.io-index" 544 | checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" 545 | 546 | [[package]] 547 | name = "jobserver" 548 | version = "0.1.25" 549 | source = "registry+https://github.com/rust-lang/crates.io-index" 550 | checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" 551 | dependencies = [ 552 | "libc", 553 | ] 554 | 555 | [[package]] 556 | name = "language-tags" 557 | version = "0.3.2" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" 560 | 561 | [[package]] 562 | name = "libc" 563 | version = "0.2.139" 564 | source = "registry+https://github.com/rust-lang/crates.io-index" 565 | checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" 566 | 567 | [[package]] 568 | name = "local-channel" 569 | version = "0.1.3" 570 | source = "registry+https://github.com/rust-lang/crates.io-index" 571 | checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" 572 | dependencies = [ 573 | "futures-core", 574 | "futures-sink", 575 | "futures-util", 576 | "local-waker", 577 | ] 578 | 579 | [[package]] 580 | name = "local-waker" 581 | version = "0.1.3" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" 584 | 585 | [[package]] 586 | name = "lock_api" 587 | version = "0.4.9" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 590 | dependencies = [ 591 | "autocfg", 592 | "scopeguard", 593 | ] 594 | 595 | [[package]] 596 | name = "log" 597 | version = "0.4.17" 598 | source = "registry+https://github.com/rust-lang/crates.io-index" 599 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 600 | dependencies = [ 601 | "cfg-if", 602 | ] 603 | 604 | [[package]] 605 | name = "memchr" 606 | version = "2.5.0" 607 | source = "registry+https://github.com/rust-lang/crates.io-index" 608 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 609 | 610 | [[package]] 611 | name = "mime" 612 | version = "0.3.16" 613 | source = "registry+https://github.com/rust-lang/crates.io-index" 614 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" 615 | 616 | [[package]] 617 | name = "miniz_oxide" 618 | version = "0.6.2" 619 | source = "registry+https://github.com/rust-lang/crates.io-index" 620 | checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" 621 | dependencies = [ 622 | "adler", 623 | ] 624 | 625 | [[package]] 626 | name = "mio" 627 | version = "0.8.5" 628 | source = "registry+https://github.com/rust-lang/crates.io-index" 629 | checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" 630 | dependencies = [ 631 | "libc", 632 | "log", 633 | "wasi", 634 | "windows-sys", 635 | ] 636 | 637 | [[package]] 638 | name = "num_cpus" 639 | version = "1.15.0" 640 | source = "registry+https://github.com/rust-lang/crates.io-index" 641 | checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" 642 | dependencies = [ 643 | "hermit-abi", 644 | "libc", 645 | ] 646 | 647 | [[package]] 648 | name = "once_cell" 649 | version = "1.16.0" 650 | source = "registry+https://github.com/rust-lang/crates.io-index" 651 | checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" 652 | 653 | [[package]] 654 | name = "parking_lot" 655 | version = "0.12.1" 656 | source = "registry+https://github.com/rust-lang/crates.io-index" 657 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 658 | dependencies = [ 659 | "lock_api", 660 | "parking_lot_core", 661 | ] 662 | 663 | [[package]] 664 | name = "parking_lot_core" 665 | version = "0.9.5" 666 | source = "registry+https://github.com/rust-lang/crates.io-index" 667 | checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" 668 | dependencies = [ 669 | "cfg-if", 670 | "libc", 671 | "redox_syscall", 672 | "smallvec", 673 | "windows-sys", 674 | ] 675 | 676 | [[package]] 677 | name = "paste" 678 | version = "1.0.11" 679 | source = "registry+https://github.com/rust-lang/crates.io-index" 680 | checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" 681 | 682 | [[package]] 683 | name = "percent-encoding" 684 | version = "2.2.0" 685 | source = "registry+https://github.com/rust-lang/crates.io-index" 686 | checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" 687 | 688 | [[package]] 689 | name = "pin-project-lite" 690 | version = "0.2.9" 691 | source = "registry+https://github.com/rust-lang/crates.io-index" 692 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 693 | 694 | [[package]] 695 | name = "pin-utils" 696 | version = "0.1.0" 697 | source = "registry+https://github.com/rust-lang/crates.io-index" 698 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 699 | 700 | [[package]] 701 | name = "ppv-lite86" 702 | version = "0.2.17" 703 | source = "registry+https://github.com/rust-lang/crates.io-index" 704 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 705 | 706 | [[package]] 707 | name = "proc-macro2" 708 | version = "1.0.49" 709 | source = "registry+https://github.com/rust-lang/crates.io-index" 710 | checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" 711 | dependencies = [ 712 | "unicode-ident", 713 | ] 714 | 715 | [[package]] 716 | name = "quote" 717 | version = "1.0.23" 718 | source = "registry+https://github.com/rust-lang/crates.io-index" 719 | checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" 720 | dependencies = [ 721 | "proc-macro2", 722 | ] 723 | 724 | [[package]] 725 | name = "rand" 726 | version = "0.8.5" 727 | source = "registry+https://github.com/rust-lang/crates.io-index" 728 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 729 | dependencies = [ 730 | "libc", 731 | "rand_chacha", 732 | "rand_core", 733 | ] 734 | 735 | [[package]] 736 | name = "rand_chacha" 737 | version = "0.3.1" 738 | source = "registry+https://github.com/rust-lang/crates.io-index" 739 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 740 | dependencies = [ 741 | "ppv-lite86", 742 | "rand_core", 743 | ] 744 | 745 | [[package]] 746 | name = "rand_core" 747 | version = "0.6.4" 748 | source = "registry+https://github.com/rust-lang/crates.io-index" 749 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 750 | dependencies = [ 751 | "getrandom", 752 | ] 753 | 754 | [[package]] 755 | name = "redox_syscall" 756 | version = "0.2.16" 757 | source = "registry+https://github.com/rust-lang/crates.io-index" 758 | checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 759 | dependencies = [ 760 | "bitflags", 761 | ] 762 | 763 | [[package]] 764 | name = "regex" 765 | version = "1.7.0" 766 | source = "registry+https://github.com/rust-lang/crates.io-index" 767 | checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" 768 | dependencies = [ 769 | "aho-corasick", 770 | "memchr", 771 | "regex-syntax", 772 | ] 773 | 774 | [[package]] 775 | name = "regex-syntax" 776 | version = "0.6.28" 777 | source = "registry+https://github.com/rust-lang/crates.io-index" 778 | checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" 779 | 780 | [[package]] 781 | name = "rustc_version" 782 | version = "0.4.0" 783 | source = "registry+https://github.com/rust-lang/crates.io-index" 784 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 785 | dependencies = [ 786 | "semver", 787 | ] 788 | 789 | [[package]] 790 | name = "ryu" 791 | version = "1.0.12" 792 | source = "registry+https://github.com/rust-lang/crates.io-index" 793 | checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" 794 | 795 | [[package]] 796 | name = "scopeguard" 797 | version = "1.1.0" 798 | source = "registry+https://github.com/rust-lang/crates.io-index" 799 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 800 | 801 | [[package]] 802 | name = "semver" 803 | version = "1.0.16" 804 | source = "registry+https://github.com/rust-lang/crates.io-index" 805 | checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" 806 | 807 | [[package]] 808 | name = "serde" 809 | version = "1.0.152" 810 | source = "registry+https://github.com/rust-lang/crates.io-index" 811 | checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" 812 | 813 | [[package]] 814 | name = "serde_json" 815 | version = "1.0.91" 816 | source = "registry+https://github.com/rust-lang/crates.io-index" 817 | checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" 818 | dependencies = [ 819 | "itoa", 820 | "ryu", 821 | "serde", 822 | ] 823 | 824 | [[package]] 825 | name = "serde_urlencoded" 826 | version = "0.7.1" 827 | source = "registry+https://github.com/rust-lang/crates.io-index" 828 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" 829 | dependencies = [ 830 | "form_urlencoded", 831 | "itoa", 832 | "ryu", 833 | "serde", 834 | ] 835 | 836 | [[package]] 837 | name = "sha1" 838 | version = "0.10.5" 839 | source = "registry+https://github.com/rust-lang/crates.io-index" 840 | checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" 841 | dependencies = [ 842 | "cfg-if", 843 | "cpufeatures", 844 | "digest", 845 | ] 846 | 847 | [[package]] 848 | name = "signal-hook-registry" 849 | version = "1.4.0" 850 | source = "registry+https://github.com/rust-lang/crates.io-index" 851 | checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" 852 | dependencies = [ 853 | "libc", 854 | ] 855 | 856 | [[package]] 857 | name = "slab" 858 | version = "0.4.7" 859 | source = "registry+https://github.com/rust-lang/crates.io-index" 860 | checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" 861 | dependencies = [ 862 | "autocfg", 863 | ] 864 | 865 | [[package]] 866 | name = "smallvec" 867 | version = "1.10.0" 868 | source = "registry+https://github.com/rust-lang/crates.io-index" 869 | checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" 870 | 871 | [[package]] 872 | name = "socket2" 873 | version = "0.4.7" 874 | source = "registry+https://github.com/rust-lang/crates.io-index" 875 | checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" 876 | dependencies = [ 877 | "libc", 878 | "winapi", 879 | ] 880 | 881 | [[package]] 882 | name = "syn" 883 | version = "1.0.107" 884 | source = "registry+https://github.com/rust-lang/crates.io-index" 885 | checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" 886 | dependencies = [ 887 | "proc-macro2", 888 | "quote", 889 | "unicode-ident", 890 | ] 891 | 892 | [[package]] 893 | name = "time" 894 | version = "0.3.17" 895 | source = "registry+https://github.com/rust-lang/crates.io-index" 896 | checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" 897 | dependencies = [ 898 | "itoa", 899 | "serde", 900 | "time-core", 901 | "time-macros", 902 | ] 903 | 904 | [[package]] 905 | name = "time-core" 906 | version = "0.1.0" 907 | source = "registry+https://github.com/rust-lang/crates.io-index" 908 | checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" 909 | 910 | [[package]] 911 | name = "time-macros" 912 | version = "0.2.6" 913 | source = "registry+https://github.com/rust-lang/crates.io-index" 914 | checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" 915 | dependencies = [ 916 | "time-core", 917 | ] 918 | 919 | [[package]] 920 | name = "tinyvec" 921 | version = "1.6.0" 922 | source = "registry+https://github.com/rust-lang/crates.io-index" 923 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" 924 | dependencies = [ 925 | "tinyvec_macros", 926 | ] 927 | 928 | [[package]] 929 | name = "tinyvec_macros" 930 | version = "0.1.0" 931 | source = "registry+https://github.com/rust-lang/crates.io-index" 932 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 933 | 934 | [[package]] 935 | name = "tokio" 936 | version = "1.23.0" 937 | source = "registry+https://github.com/rust-lang/crates.io-index" 938 | checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" 939 | dependencies = [ 940 | "autocfg", 941 | "bytes", 942 | "libc", 943 | "memchr", 944 | "mio", 945 | "parking_lot", 946 | "pin-project-lite", 947 | "signal-hook-registry", 948 | "socket2", 949 | "windows-sys", 950 | ] 951 | 952 | [[package]] 953 | name = "tokio-util" 954 | version = "0.7.4" 955 | source = "registry+https://github.com/rust-lang/crates.io-index" 956 | checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" 957 | dependencies = [ 958 | "bytes", 959 | "futures-core", 960 | "futures-sink", 961 | "pin-project-lite", 962 | "tokio", 963 | "tracing", 964 | ] 965 | 966 | [[package]] 967 | name = "tracing" 968 | version = "0.1.37" 969 | source = "registry+https://github.com/rust-lang/crates.io-index" 970 | checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" 971 | dependencies = [ 972 | "cfg-if", 973 | "log", 974 | "pin-project-lite", 975 | "tracing-core", 976 | ] 977 | 978 | [[package]] 979 | name = "tracing-core" 980 | version = "0.1.30" 981 | source = "registry+https://github.com/rust-lang/crates.io-index" 982 | checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" 983 | dependencies = [ 984 | "once_cell", 985 | ] 986 | 987 | [[package]] 988 | name = "typenum" 989 | version = "1.16.0" 990 | source = "registry+https://github.com/rust-lang/crates.io-index" 991 | checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" 992 | 993 | [[package]] 994 | name = "unicode-bidi" 995 | version = "0.3.8" 996 | source = "registry+https://github.com/rust-lang/crates.io-index" 997 | checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" 998 | 999 | [[package]] 1000 | name = "unicode-ident" 1001 | version = "1.0.6" 1002 | source = "registry+https://github.com/rust-lang/crates.io-index" 1003 | checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" 1004 | 1005 | [[package]] 1006 | name = "unicode-normalization" 1007 | version = "0.1.22" 1008 | source = "registry+https://github.com/rust-lang/crates.io-index" 1009 | checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" 1010 | dependencies = [ 1011 | "tinyvec", 1012 | ] 1013 | 1014 | [[package]] 1015 | name = "url" 1016 | version = "2.3.1" 1017 | source = "registry+https://github.com/rust-lang/crates.io-index" 1018 | checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" 1019 | dependencies = [ 1020 | "form_urlencoded", 1021 | "idna", 1022 | "percent-encoding", 1023 | ] 1024 | 1025 | [[package]] 1026 | name = "version_check" 1027 | version = "0.9.4" 1028 | source = "registry+https://github.com/rust-lang/crates.io-index" 1029 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1030 | 1031 | [[package]] 1032 | name = "wasi" 1033 | version = "0.11.0+wasi-snapshot-preview1" 1034 | source = "registry+https://github.com/rust-lang/crates.io-index" 1035 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 1036 | 1037 | [[package]] 1038 | name = "winapi" 1039 | version = "0.3.9" 1040 | source = "registry+https://github.com/rust-lang/crates.io-index" 1041 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1042 | dependencies = [ 1043 | "winapi-i686-pc-windows-gnu", 1044 | "winapi-x86_64-pc-windows-gnu", 1045 | ] 1046 | 1047 | [[package]] 1048 | name = "winapi-i686-pc-windows-gnu" 1049 | version = "0.4.0" 1050 | source = "registry+https://github.com/rust-lang/crates.io-index" 1051 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1052 | 1053 | [[package]] 1054 | name = "winapi-x86_64-pc-windows-gnu" 1055 | version = "0.4.0" 1056 | source = "registry+https://github.com/rust-lang/crates.io-index" 1057 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1058 | 1059 | [[package]] 1060 | name = "windows-sys" 1061 | version = "0.42.0" 1062 | source = "registry+https://github.com/rust-lang/crates.io-index" 1063 | checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" 1064 | dependencies = [ 1065 | "windows_aarch64_gnullvm", 1066 | "windows_aarch64_msvc", 1067 | "windows_i686_gnu", 1068 | "windows_i686_msvc", 1069 | "windows_x86_64_gnu", 1070 | "windows_x86_64_gnullvm", 1071 | "windows_x86_64_msvc", 1072 | ] 1073 | 1074 | [[package]] 1075 | name = "windows_aarch64_gnullvm" 1076 | version = "0.42.0" 1077 | source = "registry+https://github.com/rust-lang/crates.io-index" 1078 | checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" 1079 | 1080 | [[package]] 1081 | name = "windows_aarch64_msvc" 1082 | version = "0.42.0" 1083 | source = "registry+https://github.com/rust-lang/crates.io-index" 1084 | checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" 1085 | 1086 | [[package]] 1087 | name = "windows_i686_gnu" 1088 | version = "0.42.0" 1089 | source = "registry+https://github.com/rust-lang/crates.io-index" 1090 | checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" 1091 | 1092 | [[package]] 1093 | name = "windows_i686_msvc" 1094 | version = "0.42.0" 1095 | source = "registry+https://github.com/rust-lang/crates.io-index" 1096 | checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" 1097 | 1098 | [[package]] 1099 | name = "windows_x86_64_gnu" 1100 | version = "0.42.0" 1101 | source = "registry+https://github.com/rust-lang/crates.io-index" 1102 | checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" 1103 | 1104 | [[package]] 1105 | name = "windows_x86_64_gnullvm" 1106 | version = "0.42.0" 1107 | source = "registry+https://github.com/rust-lang/crates.io-index" 1108 | checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" 1109 | 1110 | [[package]] 1111 | name = "windows_x86_64_msvc" 1112 | version = "0.42.0" 1113 | source = "registry+https://github.com/rust-lang/crates.io-index" 1114 | checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" 1115 | 1116 | [[package]] 1117 | name = "zstd" 1118 | version = "0.11.2+zstd.1.5.2" 1119 | source = "registry+https://github.com/rust-lang/crates.io-index" 1120 | checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" 1121 | dependencies = [ 1122 | "zstd-safe", 1123 | ] 1124 | 1125 | [[package]] 1126 | name = "zstd-safe" 1127 | version = "5.0.2+zstd.1.5.2" 1128 | source = "registry+https://github.com/rust-lang/crates.io-index" 1129 | checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" 1130 | dependencies = [ 1131 | "libc", 1132 | "zstd-sys", 1133 | ] 1134 | 1135 | [[package]] 1136 | name = "zstd-sys" 1137 | version = "2.0.4+zstd.1.5.2" 1138 | source = "registry+https://github.com/rust-lang/crates.io-index" 1139 | checksum = "4fa202f2ef00074143e219d15b62ffc317d17cc33909feac471c044087cad7b0" 1140 | dependencies = [ 1141 | "cc", 1142 | "libc", 1143 | ] 1144 | -------------------------------------------------------------------------------- /rust-actix-hello-world/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "actix-hello-world" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | actix-web = "4" 10 | 11 | -------------------------------------------------------------------------------- /rust-actix-hello-world/src/main.rs: -------------------------------------------------------------------------------- 1 | use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder}; 2 | 3 | #[get("/")] 4 | async fn hello() -> impl Responder { 5 | HttpResponse::Ok().body("Hello world!") 6 | } 7 | 8 | #[post("/echo")] 9 | async fn echo(req_body: String) -> impl Responder { 10 | HttpResponse::Ok().body(req_body) 11 | } 12 | 13 | async fn manual_hello() -> impl Responder { 14 | HttpResponse::Ok().body("Hey there!") 15 | } 16 | 17 | #[actix_web::main] 18 | async fn main() -> std::io::Result<()> { 19 | HttpServer::new(|| { 20 | App::new() 21 | .service(hello) 22 | .service(echo) 23 | .route("/hey", web::get().to(manual_hello)) 24 | }) 25 | .bind(("127.0.0.1", 8080))? 26 | .run() 27 | .await 28 | } -------------------------------------------------------------------------------- /rust-dangling-pointer-attempt/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "rust-dangling-pointer-attempt" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /rust-dangling-pointer-attempt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-dangling-pointer-attempt" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /rust-dangling-pointer-attempt/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let dangling_pointer = vec![1, 2, 3]; 3 | drop(dangling_pointer); 4 | println!("{:?}", dangling_pointer); 5 | } 6 | -------------------------------------------------------------------------------- /rust-deadlock/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "rust-deadlock" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /rust-deadlock/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-deadlock" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /rust-deadlock/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::{sync::{Arc, Mutex}, thread}; 2 | 3 | fn main() { 4 | let lock1 = Arc::new(Mutex::new(1)); 5 | let lock2 = Arc::new(Mutex::new(2)); 6 | 7 | let lock1_clone = lock1.clone(); 8 | let lock2_clone = lock2.clone(); 9 | 10 | let t1 = thread::spawn(move || { 11 | let _guard1 = lock1_clone.lock().unwrap(); 12 | println!("Thread 1 acquired lock 1"); 13 | thread::sleep(std::time::Duration::from_secs(1)); 14 | println!("Thread 1 trying to acquire lock 2"); 15 | let _guard2 = lock2_clone.lock().unwrap(); 16 | println!("Thread 1 acquired lock 2"); 17 | }); 18 | 19 | let t2 = thread::spawn(move || { 20 | let _guard2 = lock2.lock().unwrap(); 21 | println!("Thread 2 acquired lock 2"); 22 | thread::sleep(std::time::Duration::from_secs(1)); 23 | println!("Thread 2 trying to acquire lock 1"); 24 | let _guard1 = lock1.lock().unwrap(); 25 | println!("Thread 2 acquired lock 1"); 26 | }); 27 | 28 | t1.join().unwrap(); 29 | t2.join().unwrap(); 30 | } -------------------------------------------------------------------------------- /rust-mpmc-sample/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "autocfg" 7 | version = "1.1.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 10 | 11 | [[package]] 12 | name = "cfg-if" 13 | version = "1.0.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 16 | 17 | [[package]] 18 | name = "crossbeam" 19 | version = "0.8.2" 20 | source = "registry+https://github.com/rust-lang/crates.io-index" 21 | checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" 22 | dependencies = [ 23 | "cfg-if", 24 | "crossbeam-channel", 25 | "crossbeam-deque", 26 | "crossbeam-epoch", 27 | "crossbeam-queue", 28 | "crossbeam-utils", 29 | ] 30 | 31 | [[package]] 32 | name = "crossbeam-channel" 33 | version = "0.5.6" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" 36 | dependencies = [ 37 | "cfg-if", 38 | "crossbeam-utils", 39 | ] 40 | 41 | [[package]] 42 | name = "crossbeam-deque" 43 | version = "0.8.2" 44 | source = "registry+https://github.com/rust-lang/crates.io-index" 45 | checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" 46 | dependencies = [ 47 | "cfg-if", 48 | "crossbeam-epoch", 49 | "crossbeam-utils", 50 | ] 51 | 52 | [[package]] 53 | name = "crossbeam-epoch" 54 | version = "0.9.13" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" 57 | dependencies = [ 58 | "autocfg", 59 | "cfg-if", 60 | "crossbeam-utils", 61 | "memoffset", 62 | "scopeguard", 63 | ] 64 | 65 | [[package]] 66 | name = "crossbeam-queue" 67 | version = "0.3.8" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" 70 | dependencies = [ 71 | "cfg-if", 72 | "crossbeam-utils", 73 | ] 74 | 75 | [[package]] 76 | name = "crossbeam-utils" 77 | version = "0.8.14" 78 | source = "registry+https://github.com/rust-lang/crates.io-index" 79 | checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" 80 | dependencies = [ 81 | "cfg-if", 82 | ] 83 | 84 | [[package]] 85 | name = "memoffset" 86 | version = "0.7.1" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" 89 | dependencies = [ 90 | "autocfg", 91 | ] 92 | 93 | [[package]] 94 | name = "rust-mpmc-sample" 95 | version = "0.1.0" 96 | dependencies = [ 97 | "crossbeam", 98 | ] 99 | 100 | [[package]] 101 | name = "scopeguard" 102 | version = "1.1.0" 103 | source = "registry+https://github.com/rust-lang/crates.io-index" 104 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 105 | -------------------------------------------------------------------------------- /rust-mpmc-sample/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-mpmc-sample" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | crossbeam = "0.8.1" 10 | -------------------------------------------------------------------------------- /rust-mpmc-sample/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | use crossbeam::channel::{unbounded}; 3 | 4 | fn main() { 5 | // Create an unbounded MPMC channel. 6 | let (sender, receiver) = unbounded(); 7 | 8 | // Spawn producer threads. 9 | for i in 0..5 { 10 | let sender = sender.clone(); 11 | thread::spawn(move || { 12 | let _ = sender.send(i * 2); 13 | }); 14 | } 15 | 16 | // Spawn consumer threads. 17 | let mut handles = Vec::new(); 18 | for _ in 0..5 { 19 | let receiver = receiver.clone(); 20 | handles.push(thread::spawn(move || { 21 | let val = receiver.recv().unwrap(); 22 | println!("received value: {}", val); 23 | })); 24 | } 25 | // Wait for all threads to finish. 26 | for handle in handles { 27 | if let Err(e) = handle.join() { 28 | println!("thread panicked: {:?}", e); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /rust-mpsc-sample/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "rust-mpsc-sample" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /rust-mpsc-sample/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-mpsc-sample" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /rust-mpsc-sample/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | use std::sync::mpsc; 3 | 4 | fn main() { 5 | let (tx, rx) = mpsc::channel(); 6 | 7 | // Start a new thread that will send a string 8 | thread::spawn(move || { 9 | let msg = "hello from a new thread!".to_string(); 10 | tx.send(msg).unwrap(); 11 | }); 12 | 13 | // Wait for the message in the main thread 14 | let received = rx.recv().unwrap(); 15 | println!("Received: {}", received); 16 | } 17 | -------------------------------------------------------------------------------- /rust-null-pointer/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "rust-null-pointer" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /rust-null-pointer/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-null-pointer" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /rust-null-pointer/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s: Option = None; 3 | 4 | match s { 5 | Some(i) => println!("Some: {}", i), 6 | None => println!("None"), 7 | } 8 | } -------------------------------------------------------------------------------- /rust-ref-cell-crash/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "rust-ref-cell-crash" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /rust-ref-cell-crash/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-ref-cell-crash" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /rust-ref-cell-crash/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::cell::RefCell; 2 | 3 | fn main() { 4 | let x = RefCell::new("sdfsdf"); 5 | let y = x.borrow_mut(); 6 | let w = x.borrow_mut(); 7 | println!("{}", y); 8 | } --------------------------------------------------------------------------------