├── .gitignore ├── .travis.yml ├── COPYING ├── Changelog.md ├── README.md ├── project.clj ├── src └── dynapath │ ├── defaults.clj │ ├── dynamic_classpath.clj │ └── util.clj └── test └── dynapath ├── defaults_test.clj └── util_test.clj /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml* 6 | *.jar 7 | *.class 8 | .lein-deps-sum 9 | .lein-failures 10 | .lein-plugins 11 | .lein-repl-history 12 | .nrepl-port 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: clojure 2 | script: lein test-all 3 | jdk: 4 | - openjdk8 5 | - openjdk11 6 | - openjdk-ea 7 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Source code distributed under the Eclipse Public License - v 1.0: 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE 4 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF 5 | THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial code and 12 | documentation distributed under this Agreement, and 13 | 14 | b) in the case of each subsequent Contributor: 15 | 16 | i) changes to the Program, and 17 | 18 | ii) additions to the Program; 19 | 20 | where such changes and/or additions to the Program originate from and 21 | are distributed by that particular Contributor. A Contribution 22 | 'originates' from a Contributor if it was added to the Program by such 23 | Contributor itself or anyone acting on such Contributor's 24 | behalf. Contributions do not include additions to the Program which: 25 | (i) are separate modules of software distributed in conjunction with 26 | the Program under their own license agreement, and (ii) are not 27 | derivative works of the Program. 28 | 29 | "Contributor" means any person or entity that distributes the Program. 30 | 31 | "Licensed Patents" mean patent claims licensable by a Contributor 32 | which are necessarily infringed by the use or sale of its Contribution 33 | alone or when combined with the Program. 34 | 35 | "Program" means the Contributions distributed in accordance with this 36 | Agreement. 37 | 38 | "Recipient" means anyone who receives the Program under this 39 | Agreement, including all Contributors. 40 | 41 | 2. GRANT OF RIGHTS 42 | 43 | a) Subject to the terms of this Agreement, each Contributor hereby 44 | grants Recipient a non-exclusive, worldwide, royalty-free copyright 45 | license to reproduce, prepare derivative works of, publicly display, 46 | publicly perform, distribute and sublicense the Contribution of such 47 | Contributor, if any, and such derivative works, in source code and 48 | object code form. 49 | 50 | b) Subject to the terms of this Agreement, each Contributor hereby 51 | grants Recipient a non-exclusive, worldwide, royalty-free patent 52 | license under Licensed Patents to make, use, sell, offer to sell, 53 | import and otherwise transfer the Contribution of such Contributor, if 54 | any, in source code and object code form. This patent license shall 55 | apply to the combination of the Contribution and the Program if, at 56 | the time the Contribution is added by the Contributor, such addition 57 | of the Contribution causes such combination to be covered by the 58 | Licensed Patents. The patent license shall not apply to any other 59 | combinations which include the Contribution. No hardware per se is 60 | licensed hereunder. 61 | 62 | c) Recipient understands that although each Contributor grants the 63 | licenses to its Contributions set forth herein, no assurances are 64 | provided by any Contributor that the Program does not infringe the 65 | patent or other intellectual property rights of any other entity. Each 66 | Contributor disclaims any liability to Recipient for claims brought by 67 | any other entity based on infringement of intellectual property rights 68 | or otherwise. As a condition to exercising the rights and licenses 69 | granted hereunder, each Recipient hereby assumes sole responsibility 70 | to secure any other intellectual property rights needed, if any. For 71 | example, if a third party patent license is required to allow 72 | Recipient to distribute the Program, it is Recipient's responsibility 73 | to acquire that license before distributing the Program. 74 | 75 | d) Each Contributor represents that to its knowledge it has sufficient 76 | copyright rights in its Contribution, if any, to grant the copyright 77 | license set forth in this Agreement. 78 | 79 | 3. REQUIREMENTS 80 | 81 | A Contributor may choose to distribute the Program in object code form 82 | under its own license agreement, provided that: 83 | 84 | a) it complies with the terms and conditions of this Agreement; and 85 | 86 | b) its license agreement: 87 | 88 | i) effectively disclaims on behalf of all Contributors all warranties 89 | and conditions, express and implied, including warranties or 90 | conditions of title and non-infringement, and implied warranties or 91 | conditions of merchantability and fitness for a particular purpose; 92 | 93 | ii) effectively excludes on behalf of all Contributors all liability 94 | for damages, including direct, indirect, special, incidental and 95 | consequential damages, such as lost profits; 96 | 97 | iii) states that any provisions which differ from this Agreement are 98 | offered by that Contributor alone and not by any other party; and 99 | 100 | iv) states that source code for the Program is available from such 101 | Contributor, and informs licensees how to obtain it in a reasonable 102 | manner on or through a medium customarily used for software exchange. 103 | 104 | When the Program is made available in source code form: 105 | 106 | a) it must be made available under this Agreement; and 107 | 108 | b) a copy of this Agreement must be included with each copy of the Program. 109 | 110 | Contributors may not remove or alter any copyright notices contained 111 | within the Program. 112 | 113 | Each Contributor must identify itself as the originator of its 114 | Contribution, if any, in a manner that reasonably allows subsequent 115 | Recipients to identify the originator of the Contribution. 116 | 117 | 4. COMMERCIAL DISTRIBUTION 118 | 119 | Commercial distributors of software may accept certain 120 | responsibilities with respect to end users, business partners and the 121 | like. While this license is intended to facilitate the commercial use 122 | of the Program, the Contributor who includes the Program in a 123 | commercial product offering should do so in a manner which does not 124 | create potential liability for other Contributors. Therefore, if a 125 | Contributor includes the Program in a commercial product offering, 126 | such Contributor ("Commercial Contributor") hereby agrees to defend 127 | and indemnify every other Contributor ("Indemnified Contributor") 128 | against any losses, damages and costs (collectively "Losses") arising 129 | from claims, lawsuits and other legal actions brought by a third party 130 | against the Indemnified Contributor to the extent caused by the acts 131 | or omissions of such Commercial Contributor in connection with its 132 | distribution of the Program in a commercial product offering. The 133 | obligations in this section do not apply to any claims or Losses 134 | relating to any actual or alleged intellectual property 135 | infringement. In order to qualify, an Indemnified Contributor must: a) 136 | promptly notify the Commercial Contributor in writing of such claim, 137 | and b) allow the Commercial Contributor tocontrol, and cooperate with 138 | the Commercial Contributor in, the defense and any related settlement 139 | negotiations. The Indemnified Contributor may participate in any such 140 | claim at its own expense. 141 | 142 | For example, a Contributor might include the Program in a commercial 143 | product offering, Product X. That Contributor is then a Commercial 144 | Contributor. If that Commercial Contributor then makes performance 145 | claims, or offers warranties related to Product X, those performance 146 | claims and warranties are such Commercial Contributor's responsibility 147 | alone. Under this section, the Commercial Contributor would have to 148 | defend claims against the other Contributors related to those 149 | performance claims and warranties, and if a court requires any other 150 | Contributor to pay any damages as a result, the Commercial Contributor 151 | must pay those damages. 152 | 153 | 5. NO WARRANTY 154 | 155 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS 156 | PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 157 | KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 158 | WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY 159 | OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely 160 | responsible for determining the appropriateness of using and 161 | distributing the Program and assumes all risks associated with its 162 | exercise of rights under this Agreement , including but not limited to 163 | the risks and costs of program errors, compliance with applicable 164 | laws, damage to or loss of data, programs or equipment, and 165 | unavailability or interruption of operations. 166 | 167 | 6. DISCLAIMER OF LIABILITY 168 | 169 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR 170 | ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, 171 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING 172 | WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF 173 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 174 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR 175 | DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 176 | HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 177 | 178 | 7. GENERAL 179 | 180 | If any provision of this Agreement is invalid or unenforceable under 181 | applicable law, it shall not affect the validity or enforceability of 182 | the remainder of the terms of this Agreement, and without further 183 | action by the parties hereto, such provision shall be reformed to the 184 | minimum extent necessary to make such provision valid and enforceable. 185 | 186 | If Recipient institutes patent litigation against any entity 187 | (including a cross-claim or counterclaim in a lawsuit) alleging that 188 | the Program itself (excluding combinations of the Program with other 189 | software or hardware) infringes such Recipient's patent(s), then such 190 | Recipient's rights granted under Section 2(b) shall terminate as of 191 | the date such litigation is filed. 192 | 193 | All Recipient's rights under this Agreement shall terminate if it 194 | fails to comply with any of the material terms or conditions of this 195 | Agreement and does not cure such failure in a reasonable period of 196 | time after becoming aware of such noncompliance. If all Recipient's 197 | rights under this Agreement terminate, Recipient agrees to cease use 198 | and distribution of the Program as soon as reasonably 199 | practicable. However, Recipient's obligations under this Agreement and 200 | any licenses granted by Recipient relating to the Program shall 201 | continue and survive. 202 | 203 | Everyone is permitted to copy and distribute copies of this Agreement, 204 | but in order to avoid inconsistency the Agreement is copyrighted and 205 | may only be modified in the following manner. The Agreement Steward 206 | reserves the right to publish new versions (including revisions) of 207 | this Agreement from time to time. No one other than the Agreement 208 | Steward has the right to modify this Agreement. The Eclipse Foundation 209 | is the initial Agreement Steward. The Eclipse Foundation may assign 210 | the responsibility to serve as the Agreement Steward to a suitable 211 | separate entity. Each new version of the Agreement will be given a 212 | distinguishing version number. The Program (including Contributions) 213 | may always be distributed subject to the version of the Agreement 214 | under which it was received. In addition, after a new version of the 215 | Agreement is published, Contributor may elect to distribute the 216 | Program (including its Contributions) under the new version. Except as 217 | expressly stated in Sections 2(a) and 2(b) above, Recipient receives 218 | no rights or licenses to the intellectual property of any Contributor 219 | under this Agreement, whether expressly, by implication, estoppel or 220 | otherwise. All rights in the Program not expressly granted under this 221 | Agreement are reserved. 222 | 223 | This Agreement is governed by the laws of the State of New York and 224 | the intellectual property laws of the United States of America. No 225 | party to this Agreement will bring a legal action under this Agreement 226 | more than one year after the cause of action arose. Each party waives 227 | its rights to a jury trial in any resulting litigation. 228 | 229 | 230 | 231 | Images distributed under the Creative Commons Attribution + ShareAlike 232 | License version 3.0: 233 | 234 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS 235 | CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS 236 | PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE 237 | WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS 238 | PROHIBITED. 239 | 240 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND 241 | AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS 242 | LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU 243 | THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH 244 | TERMS AND CONDITIONS. 245 | 246 | 1. Definitions 247 | 248 | "Adaptation" means a work based upon the Work, or upon the Work 249 | and other pre-existing works, such as a translation, adaptation, 250 | derivative work, arrangement of music or other alterations of a 251 | literary or artistic work, or phonogram or performance and 252 | includes cinematographic adaptations or any other form in which 253 | the Work may be recast, transformed, or adapted including in any 254 | form recognizably derived from the original, except that a work 255 | that constitutes a Collection will not be considered an Adaptation 256 | for the purpose of this License. For the avoidance of doubt, where 257 | the Work is a musical work, performance or phonogram, the 258 | synchronization of the Work in timed-relation with a moving image 259 | ("synching") will be considered an Adaptation for the purpose of 260 | this License. 261 | 262 | "Collection" means a collection of literary or artistic works, 263 | such as encyclopedias and anthologies, or performances, phonograms 264 | or broadcasts, or other works or subject matter other than works 265 | listed in Section 1(f) below, which, by reason of the selection 266 | and arrangement of their contents, constitute intellectual 267 | creations, in which the Work is included in its entirety in 268 | unmodified form along with one or more other contributions, each 269 | constituting separate and independent works in themselves, which 270 | together are assembled into a collective whole. A work that 271 | constitutes a Collection will not be considered an Adaptation (as 272 | defined below) for the purposes of this License. 273 | 274 | "Creative Commons Compatible License" means a license that is 275 | listed at http://creativecommons.org/compatiblelicenses that has 276 | been approved by Creative Commons as being essentially equivalent 277 | to this License, including, at a minimum, because that license: 278 | (i) contains terms that have the same purpose, meaning and effect 279 | as the License Elements of this License; and, (ii) explicitly 280 | permits the relicensing of adaptations of works made available 281 | under that license under this License or a Creative Commons 282 | jurisdiction license with the same License Elements as this 283 | License. 284 | 285 | "Distribute" means to make available to the public the original 286 | and copies of the Work or Adaptation, as appropriate, through sale 287 | or other transfer of ownership. 288 | 289 | "License Elements" means the following high-level license 290 | attributes as selected by Licensor and indicated in the title of 291 | this License: Attribution, ShareAlike. 292 | 293 | "Licensor" means the individual, individuals, entity or entities 294 | that offer(s) the Work under the terms of this License. 295 | 296 | "Original Author" means, in the case of a literary or artistic 297 | work, the individual, individuals, entity or entities who created 298 | the Work or if no individual or entity can be identified, the 299 | publisher; and in addition (i) in the case of a performance the 300 | actors, singers, musicians, dancers, and other persons who act, 301 | sing, deliver, declaim, play in, interpret or otherwise perform 302 | literary or artistic works or expressions of folklore; (ii) in the 303 | case of a phonogram the producer being the person or legal entity 304 | who first fixes the sounds of a performance or other sounds; and, 305 | (iii) in the case of broadcasts, the organization that transmits 306 | the broadcast. 307 | 308 | "Work" means the literary and/or artistic work offered under the 309 | terms of this License including without limitation any production 310 | in the literary, scientific and artistic domain, whatever may be 311 | the mode or form of its expression including digital form, such as 312 | a book, pamphlet and other writing; a lecture, address, sermon or 313 | other work of the same nature; a dramatic or dramatico-musical 314 | work; a choreographic work or entertainment in dumb show; a 315 | musical composition with or without words; a cinematographic work 316 | to which are assimilated works expressed by a process analogous to 317 | cinematography; a work of drawing, painting, architecture, 318 | sculpture, engraving or lithography; a photographic work to which 319 | are assimilated works expressed by a process analogous to 320 | photography; a work of applied art; an illustration, map, plan, 321 | sketch or three-dimensional work relative to geography, 322 | topography, architecture or science; a performance; a broadcast; a 323 | phonogram; a compilation of data to the extent it is protected as 324 | a copyrightable work; or a work performed by a variety or circus 325 | performer to the extent it is not otherwise considered a literary 326 | or artistic work. 327 | 328 | "You" means an individual or entity exercising rights under this 329 | License who has not previously violated the terms of this License 330 | with respect to the Work, or who has received express permission 331 | from the Licensor to exercise rights under this License despite a 332 | previous violation. 333 | 334 | "Publicly Perform" means to perform public recitations of the Work 335 | and to communicate to the public those public recitations, by any 336 | means or process, including by wire or wireless means or public 337 | digital performances; to make available to the public Works in 338 | such a way that members of the public may access these Works from 339 | a place and at a place individually chosen by them; to perform the 340 | Work to the public by any means or process and the communication 341 | to the public of the performances of the Work, including by public 342 | digital performance; to broadcast and rebroadcast the Work by any 343 | means including signs, sounds or images. 344 | 345 | "Reproduce" means to make copies of the Work by any means 346 | including without limitation by sound or visual recordings and the 347 | right of fixation and reproducing fixations of the Work, including 348 | storage of a protected performance or phonogram in digital form or 349 | other electronic medium. 350 | 351 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, 352 | limit, or restrict any uses free from copyright or rights arising from 353 | limitations or exceptions that are provided for in connection with the 354 | copyright protection under copyright law or other applicable laws. 355 | 356 | 3. License Grant. Subject to the terms and conditions of this License, 357 | Licensor hereby grants You a worldwide, royalty-free, non-exclusive, 358 | perpetual (for the duration of the applicable copyright) license to 359 | exercise the rights in the Work as stated below: 360 | 361 | to Reproduce the Work, to incorporate the Work into one or more 362 | Collections, and to Reproduce the Work as incorporated in the 363 | Collections; 364 | 365 | to create and Reproduce Adaptations provided that any such 366 | Adaptation, including any translation in any medium, takes 367 | reasonable steps to clearly label, demarcate or otherwise identify 368 | that changes were made to the original Work. For example, a 369 | translation could be marked "The original work was translated from 370 | English to Spanish," or a modification could indicate "The 371 | original work has been modified."; 372 | 373 | to Distribute and Publicly Perform the Work including as 374 | incorporated in Collections; and, 375 | 376 | to Distribute and Publicly Perform Adaptations. 377 | 378 | For the avoidance of doubt: 379 | 380 | Non-waivable Compulsory License Schemes. In those 381 | jurisdictions in which the right to collect royalties through 382 | any statutory or compulsory licensing scheme cannot be waived, 383 | the Licensor reserves the exclusive right to collect such 384 | royalties for any exercise by You of the rights granted under 385 | this License; 386 | 387 | Waivable Compulsory License Schemes. In those jurisdictions in 388 | which the right to collect royalties through any statutory or 389 | compulsory licensing scheme can be waived, the Licensor waives 390 | the exclusive right to collect such royalties for any exercise 391 | by You of the rights granted under this License; and, 392 | 393 | Voluntary License Schemes. The Licensor waives the right to 394 | collect royalties, whether individually or, in the event that 395 | the Licensor is a member of a collecting society that 396 | administers voluntary licensing schemes, via that society, 397 | from any exercise by You of the rights granted under this 398 | License. 399 | 400 | The above rights may be exercised in all media and formats whether now 401 | known or hereafter devised. The above rights include the right to make 402 | such modifications as are technically necessary to exercise the rights 403 | in other media and formats. Subject to Section 8(f), all rights not 404 | expressly granted by Licensor are hereby reserved. 405 | 406 | 4. Restrictions. The license granted in Section 3 above is expressly 407 | made subject to and limited by the following restrictions: 408 | 409 | You may Distribute or Publicly Perform the Work only under the 410 | terms of this License. You must include a copy of, or the Uniform 411 | Resource Identifier (URI) for, this License with every copy of the 412 | Work You Distribute or Publicly Perform. You may not offer or 413 | impose any terms on the Work that restrict the terms of this 414 | License or the ability of the recipient of the Work to exercise 415 | the rights granted to that recipient under the terms of the 416 | License. You may not sublicense the Work. You must keep intact all 417 | notices that refer to this License and to the disclaimer of 418 | warranties with every copy of the Work You Distribute or Publicly 419 | Perform. When You Distribute or Publicly Perform the Work, You may 420 | not impose any effective technological measures on the Work that 421 | restrict the ability of a recipient of the Work from You to 422 | exercise the rights granted to that recipient under the terms of 423 | the License. This Section 4(a) applies to the Work as incorporated 424 | in a Collection, but this does not require the Collection apart 425 | from the Work itself to be made subject to the terms of this 426 | License. If You create a Collection, upon notice from any Licensor 427 | You must, to the extent practicable, remove from the Collection 428 | any credit as required by Section 4(c), as requested. If You 429 | create an Adaptation, upon notice from any Licensor You must, to 430 | the extent practicable, remove from the Adaptation any credit as 431 | required by Section 4(c), as requested. 432 | 433 | You may Distribute or Publicly Perform an Adaptation only under 434 | the terms of: (i) this License; (ii) a later version of this 435 | License with the same License Elements as this License; (iii) a 436 | Creative Commons jurisdiction license (either this or a later 437 | license version) that contains the same License Elements as this 438 | License (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative 439 | Commons Compatible License. If you license the Adaptation under 440 | one of the licenses mentioned in (iv), you must comply with the 441 | terms of that license. If you license the Adaptation under the 442 | terms of any of the licenses mentioned in (i), (ii) or (iii) (the 443 | "Applicable License"), you must comply with the terms of the 444 | Applicable License generally and the following provisions: (I) You 445 | must include a copy of, or the URI for, the Applicable License 446 | with every copy of each Adaptation You Distribute or Publicly 447 | Perform; (II) You may not offer or impose any terms on the 448 | Adaptation that restrict the terms of the Applicable License or 449 | the ability of the recipient of the Adaptation to exercise the 450 | rights granted to that recipient under the terms of the Applicable 451 | License; (III) You must keep intact all notices that refer to the 452 | Applicable License and to the disclaimer of warranties with every 453 | copy of the Work as included in the Adaptation You Distribute or 454 | Publicly Perform; (IV) when You Distribute or Publicly Perform the 455 | Adaptation, You may not impose any effective technological 456 | measures on the Adaptation that restrict the ability of a 457 | recipient of the Adaptation from You to exercise the rights 458 | granted to that recipient under the terms of the Applicable 459 | License. This Section 4(b) applies to the Adaptation as 460 | incorporated in a Collection, but this does not require the 461 | Collection apart from the Adaptation itself to be made subject to 462 | the terms of the Applicable License. 463 | 464 | If You Distribute, or Publicly Perform the Work or any Adaptations 465 | or Collections, You must, unless a request has been made pursuant 466 | to Section 4(a), keep intact all copyright notices for the Work 467 | and provide, reasonable to the medium or means You are utilizing: 468 | (i) the name of the Original Author (or pseudonym, if applicable) 469 | if supplied, and/or if the Original Author and/or Licensor 470 | designate another party or parties (e.g., a sponsor institute, 471 | publishing entity, journal) for attribution ("Attribution 472 | Parties") in Licensor's copyright notice, terms of service or by 473 | other reasonable means, the name of such party or parties; (ii) 474 | the title of the Work if supplied; (iii) to the extent reasonably 475 | practicable, the URI, if any, that Licensor specifies to be 476 | associated with the Work, unless such URI does not refer to the 477 | copyright notice or licensing information for the Work; and (iv) , 478 | consistent with Ssection 3(b), in the case of an Adaptation, a 479 | credit identifying the use of the Work in the Adaptation (e.g., 480 | "French translation of the Work by Original Author," or 481 | "Screenplay based on original Work by Original Author"). The 482 | credit required by this Section 4(c) may be implemented in any 483 | reasonable manner; provided, however, that in the case of a 484 | Adaptation or Collection, at a minimum such credit will appear, if 485 | a credit for all contributing authors of the Adaptation or 486 | Collection appears, then as part of these credits and in a manner 487 | at least as prominent as the credits for the other contributing 488 | authors. For the avoidance of doubt, You may only use the credit 489 | required by this Section for the purpose of attribution in the 490 | manner set out above and, by exercising Your rights under this 491 | License, You may not implicitly or explicitly assert or imply any 492 | connection with, sponsorship or endorsement by the Original 493 | Author, Licensor and/or Attribution Parties, as appropriate, of 494 | You or Your use of the Work, without the separate, express prior 495 | written permission of the Original Author, Licensor and/or 496 | Attribution Parties. 497 | 498 | Except as otherwise agreed in writing by the Licensor or as may be 499 | otherwise permitted by applicable law, if You Reproduce, 500 | Distribute or Publicly Perform the Work either by itself or as 501 | part of any Adaptations or Collections, You must not distort, 502 | mutilate, modify or take other derogatory action in relation to 503 | the Work which would be prejudicial to the Original Author's honor 504 | or reputation. Licensor agrees that in those jurisdictions 505 | (e.g. Japan), in which any exercise of the right granted in 506 | Section 3(b) of this License (the right to make Adaptations) would 507 | be deemed to be a distortion, mutilation, modification or other 508 | derogatory action prejudicial to the Original Author's honor and 509 | reputation, the Licensor will waive or not assert, as appropriate, 510 | this Section, to the fullest extent permitted by the applicable 511 | national law, to enable You to reasonably exercise Your right 512 | under Section 3(b) of this License (right to make Adaptations) but 513 | not otherwise. 514 | 515 | 5. Representations, Warranties and Disclaimer 516 | 517 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, 518 | LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR 519 | WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, 520 | STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF 521 | TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, 522 | NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, 523 | OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT 524 | DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED 525 | WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 526 | 527 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY 528 | APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY 529 | LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR 530 | EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, 531 | EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 532 | 533 | 7. Termination 534 | 535 | This License and the rights granted hereunder will terminate 536 | automatically upon any breach by You of the terms of this 537 | License. Individuals or entities who have received Adaptations or 538 | Collections from You under this License, however, will not have 539 | their licenses terminated provided such individuals or entities 540 | remain in full compliance with those licenses. Sections 1, 2, 5, 541 | 6, 7, and 8 will survive any termination of this License. 542 | 543 | Subject to the above terms and conditions, the license granted 544 | here is perpetual (for the duration of the applicable copyright in 545 | the Work). Notwithstanding the above, Licensor reserves the right 546 | to release the Work under different license terms or to stop 547 | distributing the Work at any time; provided, however that any such 548 | election will not serve to withdraw this License (or any other 549 | license that has been, or is required to be, granted under the 550 | terms of this License), and this License will continue in full 551 | force and effect unless terminated as stated above. 552 | 553 | 8. Miscellaneous 554 | 555 | Each time You Distribute or Publicly Perform the Work or a 556 | Collection, the Licensor offers to the recipient a license to the 557 | Work on the same terms and conditions as the license granted to 558 | You under this License. 559 | 560 | Each time You Distribute or Publicly Perform an Adaptation, 561 | Licensor offers to the recipient a license to the original Work on 562 | the same terms and conditions as the license granted to You under 563 | this License. 564 | 565 | If any provision of this License is invalid or unenforceable under 566 | applicable law, it shall not affect the validity or enforceability 567 | of the remainder of the terms of this License, and without further 568 | action by the parties to this agreement, such provision shall be 569 | reformed to the minimum extent necessary to make such provision 570 | valid and enforceable. 571 | 572 | No term or provision of this License shall be deemed waived and no 573 | breach consented to unless such waiver or consent shall be in 574 | writing and signed by the party to be charged with such waiver or 575 | consent. 576 | 577 | This License constitutes the entire agreement between the parties 578 | with respect to the Work licensed here. There are no 579 | understandings, agreements or representations with respect to the 580 | Work not specified here. Licensor shall not be bound by any 581 | additional provisions that may appear in any communication from 582 | You. This License may not be modified without the mutual written 583 | agreement of the Licensor and You. 584 | 585 | The rights granted under, and the subject matter referenced, in 586 | this License were drafted utilizing the terminology of the Berne 587 | Convention for the Protection of Literary and Artistic Works (as 588 | amended on September 28, 1979), the Rome Convention of 1961, the 589 | WIPO Copyright Treaty of 1996, the WIPO Performances and 590 | Phonograms Treaty of 1996 and the Universal Copyright Convention 591 | (as revised on July 24, 1971). These rights and subject matter 592 | take effect in the relevant jurisdiction in which the License 593 | terms are sought to be enforced according to the corresponding 594 | provisions of the implementation of those treaty provisions in the 595 | applicable national law. If the standard suite of rights granted 596 | under applicable copyright law includes additional rights not 597 | granted under this License, such additional rights are deemed to 598 | be included in the License; this License is not intended to 599 | restrict the license of any rights under applicable law. 600 | -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | # 1.1.0 - 2019-11-25 2 | 3 | * Fall back to parsing the `java.class.path` sysprop if the base 4 | loader doesn't have a dynapath implementation. This allows for some 5 | classpath value to be returned when on Java 9+. 6 | 7 | # 1.0.0 - 2017-10-25 8 | 9 | * BREAKING - Don't allow URLClassLoader to be modified. See the README 10 | for more details. 11 | 12 | # 0.2.5 - 2016-12-09 13 | 14 | * Fix URLClassLoader extension to work with Java 9 nightly builds 15 | * Resolve classes at runtime instead of compile time to resolve AOT issues with Java 9 16 | 17 | # 0.2.4 - 2016-05-27 18 | 19 | * Update default extension to work with Java 9 20 | * Remove reflection warnings 21 | 22 | # 0.2.3 - 2013-02-21 23 | 24 | * Allow the ExtClassLoader to at least be readable 25 | 26 | # 0.2.2 - 2013-02-21 27 | 28 | * Disable modification of ExtClassLoader 29 | 30 | # Anything older than 0.2.2 is fundamentally broken, and shouldn't be used 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dynapath [![Build Status](https://secure.travis-ci.org/tobias/dynapath.png?branch=master)](https://travis-ci.org/tobias/dynapath) 2 | 3 | dynapath provides a protocol and util functions for class loaders that 4 | make their effective classpaths readable and/or modifiable. 5 | 6 | ## Rationale 7 | 8 | Clojure uses a `clojure.lang.DynamicClassLoader` by default (an 9 | extension of `java.net.URLClassLoader`), which provides `.getURLs` for 10 | reading the effective classpath and `.addURL` for modifying it. It's 11 | common for projects that need to read or modify the effective 12 | classpath to assume that a `URLClassLoader` is always available. But 13 | in some environments, the available class loader may not be a 14 | `URLClassLoader`, and may not be readable or modifiable. 15 | 16 | Some projects (notably `pomegranate`) handle this by providing a 17 | protocol that can be implemented for other class loaders that may 18 | provide similar functionality. 19 | 20 | dynapath provides a protocol that is based on an extraction of 21 | pomegranate's protocol, and is intended to be a standard way for 22 | accessing or modifying the effective classpath. Using dynapath in your 23 | library instead of assuming a class loader or implementing your own 24 | protocol provides the following benefits: 25 | 26 | * Your library can work with any modifiable/readable class loader 27 | without any changes 28 | * Any project that has already implemented `DynamicClasspath` for 29 | whatever esoteric class loader they are using will not need any 30 | other changes to use your library as well 31 | 32 | ## Usage 33 | 34 | Add it as a dependency: 35 | 36 | For a Leiningen/Boot project: 37 | 38 | [org.tcrawley/dynapath "1.1.0"] 39 | 40 | For a maven project: 41 | 42 | 43 | org.tcrawley 44 | dynapath 45 | 1.1.0 46 | 47 | 48 | If you need to access or modify the effective classpath: 49 | 50 | (require '[dynapath.util :as dp]) 51 | 52 | ;; returns a seq of the urls for the classloader. Takes any classloader 53 | ;; (whether it implements DynamicClasspath or not) and does the right thing 54 | (dp/classpath-urls a-classloader) 55 | 56 | ;; returns a seq of all the urls available from the classloader and its 57 | ;; parentage chain 58 | (dp/all-classpath-urls a-classloader) 59 | 60 | ;; adds a url to the given classloader if it is addable 61 | (dp/add-classpath-url a-classloader a-url) 62 | 63 | Loading the `dynapath.defaults` namespace will automatically implement 64 | `classpath-urls` and `add-classpath-url` for `clojure.lang.DynamicClassLoader` and 65 | `classpath-urls` for `java.net.URLClassLoader`. 66 | 67 | If you need to implement `DynamicClasspath`: 68 | 69 | (require '[dynapath.dynamic-classpath :as dc]) 70 | 71 | (extend-type AReadableButNotModifiableClassLoader 72 | dc/DynamicClasspath 73 | (can-read? [_] true) 74 | (can-add? [_] false) 75 | (classpath-urls [cl] (seq ...))) 76 | 77 | (extend AReadableAndModifiableClassLoader 78 | dc/DynamicClasspath 79 | (assoc dc/base-readable-addable-classpath ;; implements can-read? and can-add? 80 | :classpath-urls (fn [cl] ...) 81 | :add-classpath-url (fn [cl url] ...))) 82 | 83 | ## Note on URLClassLoader 84 | 85 | Prior versions of dynapath implemented `add-classpath-url` for 86 | `java.net.URLClassLoader`. Doing so required reflective access to its 87 | protected `addURL` method, which would result in a warning printed to 88 | stdout under Java 9. To prevent that, that implementation has been 89 | removed, and libraries that were relying on that behavior should 90 | instead ensure they have a modifiable classloader as high in the 91 | classloader tree as they can control. For example, 92 | [boot implements its own classloader](https://github.com/boot-clj/boot/commit/a046a497a8bb7f3d1e7aa8d4db4a81c51beaef7d) 93 | to do this. 94 | 95 | ## Who's using it? 96 | 97 | * [bultitude](https://github.com/Raynes/bultitude) 98 | * [immutant](https://github.com/immutant/immutant) 99 | * [ritz](https://github.com/pallet/ritz) 100 | * [tair-repl](https://github.com/xumingming/tair-repl) 101 | * [pomegranate](https://github.com/cemerick/pomegranate) 102 | * [boot](http://boot-clj.com/) 103 | * [metabase](https://github.com/metabase/metabase) 104 | 105 | Are you using it? If so, add yourself to this list and send me a PR. 106 | 107 | ## License 108 | 109 | Copyright © 2012-2017 Tobias Crawley 110 | 111 | Distributed under the Eclipse Public License. 112 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject org.tcrawley/dynapath "1.1.1-SNAPSHOT" 2 | :description "An abstraction for modifiable/readable class loaders." 3 | :url "https://github.com/tobias/dynapath" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :deploy-repositories {"releases" 7 | {:url "https://oss.sonatype.org/service/local/staging/deploy/maven2/" 8 | :creds :gpg} 9 | "snapshots" 10 | {:url "https://oss.sonatype.org/content/repositories/snapshots/" 11 | :creds :gpg}} 12 | :scm {:url "git@github.com:tobias/dynapath.git"} 13 | :pom-addition [:developers [:developer 14 | [:name "Toby Crawley"] 15 | [:url "https://github.com/tobias/"] 16 | [:email "toby@tcrawley.org"] 17 | [:timezone "-5"]]] 18 | :aliases {"test-all" ["with-profile" "+1.4:+1.5:+1.6:+1.7:+1.8:+1.9:+1.10" "test"]} 19 | :profiles {:dev 20 | {:dependencies [[org.clojure/clojure "1.8.0"]]} 21 | :1.4 22 | {:dependencies [[org.clojure/clojure "1.4.0"]]} 23 | :1.5 24 | {:dependencies [[org.clojure/clojure "1.5.1"]]} 25 | :1.6 26 | {:dependencies [[org.clojure/clojure "1.6.0"]]} 27 | :1.7 28 | {:dependencies [[org.clojure/clojure "1.7.0"]]} 29 | :1.8 30 | {:dependencies [[org.clojure/clojure "1.8.0"]]} 31 | :1.9 32 | {:dependencies [[org.clojure/clojure "1.9.0"]]} 33 | :1.10 34 | {:dependencies [[org.clojure/clojure "1.10.1"]]}}) 35 | -------------------------------------------------------------------------------- /src/dynapath/defaults.clj: -------------------------------------------------------------------------------- 1 | (ns dynapath.defaults 2 | "Provides default DynamicClasspath implementations for DynamicClassLoader and URLClassLoader." 3 | (:require [dynapath.dynamic-classpath :as dc]) 4 | (:import clojure.lang.DynamicClassLoader 5 | java.net.URLClassLoader)) 6 | 7 | (let [base-url-classloader (assoc dc/base-readable-addable-classpath 8 | :classpath-urls #(seq (.getURLs ^URLClassLoader %)))] 9 | (when-not (extends? dc/DynamicClasspath URLClassLoader) 10 | (extend URLClassLoader 11 | dc/DynamicClasspath 12 | (assoc base-url-classloader 13 | :can-add? (constantly false))) 14 | 15 | (extend DynamicClassLoader 16 | dc/DynamicClasspath 17 | (assoc base-url-classloader 18 | :add-classpath-url (fn [^DynamicClassLoader cl url] 19 | (.addURL cl url)))))) 20 | 21 | -------------------------------------------------------------------------------- /src/dynapath/dynamic_classpath.clj: -------------------------------------------------------------------------------- 1 | (ns dynapath.dynamic-classpath 2 | "Provides the implementation of the DynamicClasspath protocol.") 3 | 4 | (defprotocol DynamicClasspath 5 | (can-read? [cl] 6 | "Must return true if classpath-urls is implemented.") 7 | (can-add? [cl] 8 | "Must return true if add-classpath-url is implemented.") 9 | (classpath-urls [cl] 10 | "Returns a seq of the given ClassLoader's URLs.") 11 | (add-classpath-url [cl url] 12 | "Adds the url to the classpath of the given ClassLoader.")) 13 | 14 | (def ^{:doc "A map that provides implementations of can-read? and can-add? that return true. 15 | Useful as a base for a DynamicClasspath implementation."} 16 | base-readable-addable-classpath 17 | {:can-add? (constantly true) 18 | :can-read? (constantly true)}) 19 | -------------------------------------------------------------------------------- /src/dynapath/util.clj: -------------------------------------------------------------------------------- 1 | (ns dynapath.util 2 | "Abstracts the getURLs and addURL functionality of URLClassLoader to a protocol." 3 | (:require [dynapath.dynamic-classpath :as dc] 4 | dynapath.defaults) ;; trigger the default implementations 5 | (:import [java.io File])) 6 | 7 | (defn addable-classpath? 8 | "Returns true if the given ClassLoader provides add-claspath-url." 9 | [cl] 10 | (and (satisfies? dc/DynamicClasspath cl) 11 | (dc/can-add? cl))) 12 | 13 | (defn readable-classpath? 14 | "Returns true if the given ClassLoader provides classpath-urls." 15 | [cl] 16 | (and (satisfies? dc/DynamicClasspath cl) 17 | (dc/can-read? cl))) 18 | 19 | (defn classpath-urls 20 | "Returns the URLs for the given ClassLoader, or nil if the ClassLoader is not readable." 21 | [cl] 22 | (if (readable-classpath? cl) 23 | (dc/classpath-urls cl))) 24 | 25 | (defn- system-classpath 26 | "Starting with Java 9, the default class loader is no longer an 27 | instance of URLClassLoader, so `classpath` returned an empty sequence. 28 | See more in clojure/java.classpath" 29 | [] 30 | (map #(-> (File. ^String %) .toURI .toURL) 31 | (.split (System/getProperty "java.class.path") 32 | (System/getProperty "path.separator")))) 33 | 34 | (defn all-classpath-urls 35 | "Walks up the parentage chain for a ClassLoader, concatenating any URLs it retrieves. 36 | If no ClassLoader is provided, RT/baseLoader is assumed." 37 | ([] 38 | (or (seq (all-classpath-urls (clojure.lang.RT/baseLoader))) 39 | (system-classpath))) 40 | ([cl] 41 | (->> (iterate #(.getParent ^ClassLoader %) cl) 42 | (take-while identity) 43 | reverse 44 | (mapcat classpath-urls) 45 | distinct))) 46 | 47 | (defn add-classpath-url 48 | "Attempts to add a url to the given ClassLoader, returning true on success. 49 | If the ClassLoader is not addable, does nothing and returns nil." 50 | [cl url] 51 | (when (addable-classpath? cl) 52 | (dc/add-classpath-url cl url) 53 | true)) 54 | -------------------------------------------------------------------------------- /test/dynapath/defaults_test.clj: -------------------------------------------------------------------------------- 1 | (ns dynapath.defaults-test 2 | (:use clojure.test 3 | dynapath.defaults 4 | dynapath.dynamic-classpath) 5 | (:import (java.net URL URLClassLoader) 6 | clojure.lang.DynamicClassLoader)) 7 | 8 | (deftype Frobble []) 9 | 10 | (let [foo-url (URL. "http://foo.bar") 11 | url-cl (URLClassLoader. (into-array [foo-url]) nil) 12 | dyn-cl (DynamicClassLoader.)] 13 | 14 | (deftest DynamicClassLoader-should-be-extended 15 | (is (satisfies? DynamicClasspath dyn-cl))) 16 | 17 | (deftest URLClassLoader-should-be-extended 18 | (is (satisfies? DynamicClasspath url-cl))) 19 | 20 | (deftest classpath-urls-should-work-for-a-URLClassLoader 21 | (is (= [foo-url] (classpath-urls url-cl)))) 22 | 23 | (deftest add-classpath-url-get-classpath-urls-should-work-for-a-DynamicClassLoader 24 | (let [url (URL. "http://ham.biscuit")] 25 | (add-classpath-url dyn-cl url) 26 | (is (= [url] (classpath-urls dyn-cl)))))) 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /test/dynapath/util_test.clj: -------------------------------------------------------------------------------- 1 | (ns dynapath.util-test 2 | (:use clojure.test 3 | dynapath.util 4 | [dynapath.dynamic-classpath :only [DynamicClasspath]]) 5 | (:import clojure.lang.DynamicClassLoader 6 | (java.net URL URLClassLoader))) 7 | 8 | (def ^:dynamic *dynamic-cl*) 9 | (def ^:dynamic *url-cl*) 10 | (def ^:dynamic *basic-cl*) 11 | (def ^:dynamic *type*) 12 | 13 | (let [urls [(URL. "http://ham.biscuit")] 14 | all-urls (conj urls (URL. "http://gravy.biscuit"))] 15 | 16 | (use-fixtures :each 17 | (fn [f] 18 | (binding [*url-cl* (URLClassLoader. (into-array urls) nil) 19 | *dynamic-cl* (DynamicClassLoader.) 20 | *basic-cl* (proxy [ClassLoader] []) 21 | *type* (let [s (gensym "Foo")] 22 | (eval `(deftype ~s [])) 23 | s)] 24 | (f)))) 25 | 26 | (deftest classpath-urls-should-work-for-a-readable-classloader 27 | (is (= urls (classpath-urls *url-cl*)))) 28 | 29 | (deftest classpath-urls-should-work-for-a-non-readable-classloader 30 | (is (nil? (classpath-urls *basic-cl*)))) 31 | 32 | (deftest all-classpath-urls-should-work-for-a-parent-with-the-urls 33 | (is (= urls (all-classpath-urls (proxy [ClassLoader] [*url-cl*]))))) 34 | 35 | (deftest all-classpath-urls-should-order-urls-properly 36 | (is (= all-urls (all-classpath-urls (URLClassLoader. (into-array [(last all-urls)]) *url-cl*))))) 37 | 38 | (deftest all-classpath-urls-should-use-the-baseLoader-when-called-with-a-zero-arity 39 | (add-classpath-url (clojure.lang.RT/baseLoader) (first urls)) 40 | (is (= (first urls) (last (all-classpath-urls))))) 41 | 42 | (deftest all-classpath-urls-always-returns-something-when-called-with-a-zero-arity 43 | (is (seq (all-classpath-urls)))) 44 | 45 | (deftest add-classpath-url-should-work-for-an-addable-classpath 46 | (is (add-classpath-url *dynamic-cl* (last all-urls))) 47 | (is (= [(last all-urls)] (classpath-urls *dynamic-cl*)))) 48 | 49 | (deftest add-classpath-url-should-work-for-a-non-addable-classpath 50 | (is (nil? (add-classpath-url *basic-cl* (last all-urls)))) 51 | (is (nil? (classpath-urls *basic-cl*)))) 52 | 53 | (deftest addable-classpath?-should-work 54 | (let [obj (eval `(new ~*type*))] 55 | (is (not (addable-classpath? obj))) 56 | (eval 57 | `(extend-type ~*type* 58 | DynamicClasspath 59 | (can-add? [~'_] true))) 60 | (is (addable-classpath? obj)) 61 | (eval 62 | `(extend-type ~*type* 63 | DynamicClasspath 64 | (can-add? [~'_] false))) 65 | (is (not (addable-classpath? obj))))) 66 | 67 | (deftest readable-classpath?-should-work 68 | (let [obj (eval `(new ~*type*))] 69 | (is (not (readable-classpath? obj))) 70 | (eval 71 | `(extend-type ~*type* 72 | DynamicClasspath 73 | (can-read? [~'_] true))) 74 | (is (readable-classpath? obj)) 75 | (eval 76 | `(extend-type ~*type* 77 | DynamicClasspath 78 | (can-read? [~'_] false))) 79 | (is (not (readable-classpath? obj)))))) 80 | 81 | --------------------------------------------------------------------------------