-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
219 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...tmoka-whitelisting/src/main/java/io/hotmoka/whitelisting/MustBeSafeLibraryCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
Copyright 2021 Fausto Spoto | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.hotmoka.whitelisting; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import io.hotmoka.whitelisting.api.WhiteListingProofObligation; | ||
import io.hotmoka.whitelisting.internal.checks.MustBeSafeLibraryCollectionCheck; | ||
|
||
/** | ||
* States that an object of a white-listed method must be a safe library collection, | ||
* exactly, hence not a user-defined collection class. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(value={ ElementType.METHOD, ElementType.PARAMETER }) | ||
@Inherited | ||
@Documented | ||
@WhiteListingProofObligation(check = MustBeSafeLibraryCollectionCheck.class) | ||
public @interface MustBeSafeLibraryCollection { | ||
} |
39 changes: 39 additions & 0 deletions
39
io-hotmoka-whitelisting/src/main/java/io/hotmoka/whitelisting/MustBeSafeLibraryMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
Copyright 2021 Fausto Spoto | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.hotmoka.whitelisting; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import io.hotmoka.whitelisting.api.WhiteListingProofObligation; | ||
import io.hotmoka.whitelisting.internal.checks.MustBeSafeLibraryMapCheck; | ||
|
||
/** | ||
* States that an object of a white-listed method must be a safe library map, | ||
* exactly, hence not a user-defined map class. | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(value={ ElementType.METHOD, ElementType.PARAMETER }) | ||
@Inherited | ||
@Documented | ||
@WhiteListingProofObligation(check = MustBeSafeLibraryMapCheck.class) | ||
public @interface MustBeSafeLibraryMap { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...c/main/java/io/hotmoka/whitelisting/internal/checks/MustBeSafeLibraryCollectionCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright 2023 Fausto Spoto | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.hotmoka.whitelisting.internal.checks; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.LinkedList; | ||
|
||
import io.hotmoka.whitelisting.api.WhiteListingPredicate; | ||
import io.hotmoka.whitelisting.api.WhiteListingWizard; | ||
|
||
/** | ||
* A check that the class of a value is exactly one of the allowed collection classes from the library | ||
* (not a user subclass then). | ||
*/ | ||
public class MustBeSafeLibraryCollectionCheck implements WhiteListingPredicate { | ||
|
||
@Override | ||
public boolean test(Object value, WhiteListingWizard wizard) { | ||
return value == null || isSafeLibraryCollection(value.getClass()); | ||
} | ||
|
||
private static boolean isSafeLibraryCollection(Class<?> clazz) { | ||
return clazz == HashSet.class || clazz == LinkedList.class || clazz == ArrayList.class; | ||
} | ||
|
||
@Override | ||
public String messageIfFailed(String methodName) { | ||
return "cannot prove that this object is a safe library collection"; | ||
} | ||
} |
Oops, something went wrong.